python政府工作报告词云

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

import jieba
import wordcloud
from scipy.misc import imread
mask = imread("chinamap.jpg")
f = open("新时代中国特色社会主义.txt","r",encoding="utf-8")
t = f.read()
f.close()
ls = jieba.lcut(t)
txt = " ".join(ls)
w = wordcloud.WordCloud(
     font_path = "msyh.ttc",
     width = 1000,height = 700,
     background_color ="white",
     max_words = 100,
     mask = mask
     )
w.generate(txt)
w.to_file("groundcloud.png")

python政府工作报告词云_第1张图片

转载于:https://my.oschina.net/zhangshsURL/blog/3010915

你可能感兴趣的:(python政府工作报告词云)