1 import jieba 2 import wordcloud 3 f = open('关于实施乡村振兴战略的意见.txt','r',encoding='utf-8') 4 t = f.read() 5 f.close() 6 ls = jieba.lcut(t) 7 txt = ''.join(ls) 8 w = wordcloud.WordCloud(font_path='msyh.ttc', width=1000, height=700, background_color='white') 9 w.generate(txt) 10 w.to_file('关于实施乡村振兴战略的意见.png')
指定输出词云的数量
1 w = wordcloud.WordCloud(font_path='msyh.ttc', width=1000, height=700, background_color='white',max_words=15)
标签:振兴,乡村,wordcloud,词云,关于,txt,绘制 From: https://www.cnblogs.com/T-2187803607/p/17147577.html