From cbce2aa5091a89dce670e68a2a55dbef70783c96 Mon Sep 17 00:00:00 2001 From: frxz751113 <156018267+frxz751113@users.noreply.github.com> Date: Mon, 19 Aug 2024 03:02:23 +0800 Subject: [PATCH] =?UTF-8?q?Update=20iptv=E6=B5=81=E7=95=85=E5=BA=A6?= =?UTF-8?q?=E6=A3=80=E6=B5=8B.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- py/iptv流畅度检测.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/py/iptv流畅度检测.py b/py/iptv流畅度检测.py index de9ff11..0d6faa7 100644 --- a/py/iptv流畅度检测.py +++ b/py/iptv流畅度检测.py @@ -593,10 +593,20 @@ with open('组播优选.txt', 'w', encoding="utf-8") as file: for line in unique_lines: file.write(line) # 确保每行后面有换行符 + '\n' # 将唯一的行追加到第二个文件 -with open('综合源.txt', 'a', encoding="utf-8") as file: - for line in unique_lines: - file.write(line) # 确保每行后面有换行符 + '\n' +#with open('综合源.txt', 'a', encoding="utf-8") as file: + #for line in unique_lines: + #file.write(line) # 确保每行后面有换行符 + '\n' +# 定义要排除的关键词列表 +excluded_keywords = ['CCTV', '卫视', '关键词3'] +# 打开原始文本文件并读取内容 +with open('组播优选.txt', 'r', encoding='utf-8') as file: + lines = file.readlines() +# 过滤掉包含关键词的行 +filtered_lines = [line for line in lines if not any(keyword in line for keyword in excluded_keywords)] +# 将过滤后的内容写入新的文本文件 +with open('综合源.txt', 'a', encoding='utf-8') as file: + file.writelines(filtered_lines) ################################################################################################任务结束,删除不必要的过程文件