Python---string

去掉某个文档里面所有的空格和字符串:comment_text=comment_text.replace(' ', '').replace("\t","").replace("\n","").strip()

jieba把中文字符串变成了list,而string.join()把list变成,一个一个加进来:cut_text = ' '.join(jieba.cut(comment_text))

文本变成字符串:comment_text = open("text.txt", 'r').read()

 

posted @ 2018-05-17 18:20  Gaoyongxian666  阅读(105)  评论(0编辑  收藏  举报