From 32c1d8b7b8239cf8a87151b7fbbc33bba97a2b8d Mon Sep 17 00:00:00 2001 From: frxz751113 <156018267+frxz751113@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:11:28 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E7=BD=91=E7=BB=9C=E6=94=B6=E9=9B=86.p?= =?UTF-8?q?y?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- py/网络收集.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/py/网络收集.py b/py/网络收集.py index aa110a5..7d205b5 100644 --- a/py/网络收集.py +++ b/py/网络收集.py @@ -363,15 +363,15 @@ keywords = ['1905', '凤凰卫视', '人间卫视', '亚洲卫视', '香港卫 excluded_pattern = '|'.join(excluded_keywords) # 将关键词列表转换为正则表达式模式 pattern = '|'.join(keywords) -with open('2.txt', 'r', encoding='utf-8') as file, open('2.txt', 'w', encoding='utf-8') as 2: - #2.write('央视频道,#genre#\n') +with open('2.txt', 'r', encoding='utf-8') as file, open('2.txt', 'w', encoding='utf-8') as a: + #a.write('央视频道,#genre#\n') for line in file: if 'genre' not in line: # 使用正则表达式检查该行是否不包含任何排除关键词 if not re.search(excluded_pattern, line): # 如果行中有任意关键字 if re.search(pattern, line): - 2.write(line) + a.write(line) ############################################################### import re