功能描述:從new_4.txt中讀取出資料,然後用jieba分詞,最後儲存到new_5.txt中.
實驗環境:Python3.7
代碼實作:
import jieba
f_out = open('./new_5.txt','wb+')
with open('./new_4.txt','r',encoding = 'utf-8') as f:
for line in f.readlines():
seg = jieba.cut(line, cut_all = False)
s='/'.join(seg)
m = list(s)
for word in m:
f_out.write(word.encode('utf-8'))
f.close()
f_out.close()