jieba库使用和好玩的词云
《决胜全面建成小康社会 夺取新时代中国特色社会主义伟大胜利》
import jieba import wordcloud f=open("C:\\Users\\Administrator\\Downloads\\python\\新建文本文档.txt","r",encoding="UTF-8") import imageio mask=imageio.imread("yes.png") t=f.read() f.close() ls=jieba.lcut(t) txt=" ".join(ls) w=wordcloud.WordCloud(font_path="msyh.ttc",mask=mask,width=1000,height=700,background_color="white") w.generate(txt) w.to_file("grwordcloud.png")