写一段使用结巴分词,分词后的数据到处成txt的代码

答:import jieba # 引入结巴分词库 words = jieba.cut(u"我爱北京天安门,天安门上太阳升") # 进行分词 with open('words.txt', 'w') as f: # 将分词结果以txt文件的形式保存 for w in words: f.write(w + '\n')

猜你喜欢

转载自blog.csdn.net/weixin_35756690/article/details/129572103