数据处理,返回txt文件

001大作业_new.py
Qw37tgf5k 3 years ago
parent 37faf3a0c8
commit 515c687827

@ -0,0 +1,22 @@
# @Time : 2021/11/1 22:47
# @Author :wenkaic
# @File : 002文件处理
# @Project : python爬虫
import re
def find_chinese(file):
pattern = re.compile(r'[^\u4e00-\u9fa5\n\\\\\\\\]')
chinese = re.sub(pattern, '', file)
chinese = re.sub('\n+','\n',chinese)
chinese = re.sub('','',chinese)
chinese = re.sub('','',chinese)
print(chinese)
return chinese
fp = open('003斗破苍穹.json', 'r', encoding='utf-8')
content=fp.read()
content1=find_chinese(content)
fp1 = open('004斗破苍穹.txt','w',encoding='utf-8')
fp1.write(content1)
fp1.close()
Loading…
Cancel
Save