import jieba
import wordcloud
txt=open("txt.txt",encoding="utf-8");
string=txt.read();
txt.close();
ls=jieba.lcut(string);
words=" ".join(ls);
w=wordcloud.WordCloud(font_path="msyh.ttc",\
max_words=15,\
);'''微软雅黑字体'''
w.generate(words);
w.to_file("txt.png");
'''
jieba库、词云库
读取数据-分隔成列表-列表转化为字符串-产生词云-生成图片
'''