标签:int utf8 lin pen join encoding read close erro
#一直因为这个编码问题没有分出来 ,后来多试验了几次就行了,供大家参考一下
import jieba
f1=open(‘all.txt‘,‘r‘,encoding=‘utf-8‘,errors=‘ignore‘)
f2=open(‘allutf8.txt‘,‘w‘,encoding=‘utf-8‘)
line=f1.readline()
while line:
seg_list=jieba.cut(line,cut_all=False)
f2.write(" ".join(seg_list))
line=f1.readline()
print(f2)
f1.close()
f2.close()
标签:int utf8 lin pen join encoding read close erro
原文地址:https://www.cnblogs.com/cyh1989/p/9038383.html