From 97d98f98e608ff391769ced783fa89ecb8d5d7ba Mon Sep 17 00:00:00 2001 From: frxz751113 <156018267+frxz751113@users.noreply.github.com> Date: Mon, 23 Sep 2024 16:58:11 +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 | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/py/网络收集.py b/py/网络收集.py index 12d0f03..124a57f 100644 --- a/py/网络收集.py +++ b/py/网络收集.py @@ -664,7 +664,31 @@ def parse_file(input_file_path, output_file_name): # parse_file('网络收集.txt', '网络收集.txt') - +def append_text_between_files(file1_path, file2_path): + with open(file1_path, 'r', encoding='utf-8') as file1: + content1 = file1.read() + lines1 = content1.split('\n') + seen = set() + unique_lines1 = [] + for line in lines1: + if line not in seen: + seen.add(line) + unique_lines1.append(line) + with open(file2_path, 'r', encoding='utf-8') as file2: + content2 = file2.read() + lines2 = content2.split('\n') + seen = set() + unique_lines2 = [] + for line in lines2: + if line not in seen: + seen.add(line) + unique_lines2.append(line) + combined_lines = unique_lines2 + unique_lines1 + with open(file2_path, 'w', encoding='utf-8') as file2: + file2.write('\n'.join(combined_lines)) +file_path1 = '网络收集.txt' +file_path2 = '综合源.txt' +append_text_between_files(file_path1, file_path2) #TXT转M3U#