Python+ Calibre 处理 中文报纸

时间:2022-06-15 17:17:43
import re
##2
line='<a href=nw.D110000renmrb_20180401_1-01.htm><script>document.write(view("领航新时代中国经济航船 "))</script></a>'
#line = line.decode("utf-8")
filtrate = re.compile(u'[^\u4E00-\u9FA5]')#非中文
filtered_str = filtrate.sub(r'', line)#replace
print (filtered_str) ##1
tempLine = '<script>document.write(view("加强党*对经济工作的集中统一领导<br>打好决胜全面建成小康社会三大攻坚战 "))</script>'
filtrate = re.compile(u'[^\u4E00-\u9FA5]')#非中文
filtered_str = filtrate.sub(r'', tempLine)#replace
print (filtered_str) filtrate = re.findall (r"[\u4e00-\u9fa5]+", tempLine) print (filtrate)

python 提取 中文