From 383644310ef86c97e2cff2a903e227144e2adf3c Mon Sep 17 00:00:00 2001 From: pw4izm9rs <2764851313@qq.com> Date: Wed, 18 Sep 2024 21:29:01 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=84=E5=8A=A0=E9=A2=981=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=96=87=E4=BB=B62?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- get_aoyun_2.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 get_aoyun_2.py diff --git a/get_aoyun_2.py b/get_aoyun_2.py new file mode 100644 index 0000000..339dcb5 --- /dev/null +++ b/get_aoyun_2.py @@ -0,0 +1,20 @@ +from collections import Counter + +# 读取新闻标题文件 +with open('aoyun.txt', 'r', encoding='utf-8') as f: + danmu_all = f.readlines() + +# 筛选包含关键词的表题 +keywords = ['冠军','夺冠','金牌','金','冠','胜利','取胜','连胜','赢','战胜','荣耀'] +ai_danmu = [danmu for danmu in danmu_all if any(keyword in danmu for keyword in keywords)] + +num = Counter(ai_danmu) +most_common = num.most_common(30) + +print("输出含有关键词的新闻标题:") +i = 0 +for content,count in most_common: + print(f"{content.strip()}") + i += 1 + +print("含有关键词的新闻标题有",i,'个') \ No newline at end of file