From 89f9e0dbfc3a5cee83fb114e32ed9370e48a17da Mon Sep 17 00:00:00 2001 From: frxz751113 <156018267+frxz751113@users.noreply.github.com> Date: Tue, 27 Aug 2024 17:11:45 +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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/py/网络收集.py b/py/网络收集.py index 5301235..9164cbc 100644 --- a/py/网络收集.py +++ b/py/网络收集.py @@ -588,6 +588,20 @@ def parse_file(input_file_path, output_file_name): # 调用函数并传入文件路径和输出文件名 parse_file('网络收集.txt', '网络收集.txt') + +#简体转繁体 +# 创建一个OpenCC对象,指定转换的规则为繁体字转简体字 +converter = OpenCC('t2s.json')#繁转简 +#converter = OpenCC('s2t.json')#简转繁 +# 打开txt文件 +with open('网络收集.txt', 'r', encoding='utf-8') as file: + traditional_text = file.read() +# 进行繁体字转简体字的转换 +simplified_text = converter.convert(traditional_text) +# 将转换后的简体字写入txt文件 +with open('网络收集.txt', 'w', encoding='utf-8') as file: + file.write(simplified_text) + ################################################################################################任务结束,删除不必要的过程文件 files_to_remove = ["2.txt", "汇总.txt"] for file in files_to_remove: