政府工作报告词云小练习

使用库:

jieba库

wordcloud库

源代码

1
2
3
4
5
6
7
8
9
10
11
12
import jieba
import wordcloud
from imageio import imread
mask = imread("chinamap.png")
f = open("新时代中国特色社会主义.txt","r", encoding="utf-8")
t = f.read()
f.close()
ls = jieba.lcut(t)
txt = " ".join(ls)
w = wordcloud.WordCloud(width=1000,height=700,background_color="white",font_path="msyh.ttc",mask=mask)
w.generate(txt)
w.to_file("wordclouddemo3.png")

效果演示

评论



2019-2020 覃浩的博客 鄂ICP备19020398号-4 正在载入...