Python 进行 结巴 分词

#一直因为这个编码问题没有分出来 ,后来多试验了几次就行了,供大家参考一下


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()
posted @ 2018-05-14 21:58  菜鸟da号  阅读(287)  评论(0编辑  收藏  举报