From 92f2dd7776ad842b48fccad49b56fe610883031b Mon Sep 17 00:00:00 2001 From: frxz751113 <156018267+frxz751113@users.noreply.github.com> Date: Mon, 26 Aug 2024 11:04:56 +0800 Subject: [PATCH] =?UTF-8?q?Update=20and=20rename=20=E4=B8=80=E9=94=85?= =?UTF-8?q?=E7=83=A9.py=20to=20=E6=94=B6=E9=9B=86.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- py/{一锅烩.py => 收集.py} | 12 ++++++++++++ 1 file changed, 12 insertions(+) rename py/{一锅烩.py => 收集.py} (96%) diff --git a/py/一锅烩.py b/py/收集.py similarity index 96% rename from py/一锅烩.py rename to py/收集.py index 7a4ce4b..9eba892 100644 --- a/py/一锅烩.py +++ b/py/收集.py @@ -65,6 +65,18 @@ def merge_txt_files(urls, output_filename='汇总.txt'): merge_txt_files(urls) +# 打开文本文件并读取内容 +def process_file(file_path): + with open(file_path, 'r', encoding='utf-8') as file: + lines = file.readlines() + # 处理每一行,去除每一行中第一个$及其后的所有内容 + processed_lines = [line.split('$', 1)[0] for line in lines] + # 将处理后的内容写回到文件 + with open(file_path, 'w', encoding='utf-8') as file: + file.write(''.join(processed_lines)) +# 调用函数并传入文件路径 +file_path = '汇总.txt' # 替换为你的文件路径 +process_file(file_path) ######################################################################################################## def remove_duplicates(input_file, output_file):