抱歉,您的浏览器无法访问本站

本页面需要浏览器支持(启用)JavaScript


了解详情 >

政府工作报告词云小练习

使用库:

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-2021 六特科技 鄂ICP备2021017381号-1 正在载入...

PoweredHexo
HostedGitHub & Coding
DNSAliyun & DNSPod
CDNjsDelivr
PictureBedjsDelivr
ThemeVolantis