关于 《新时代中国特色社会主义》 词云绘制
使用到的库:jieba wordcloud
1 import wordcloud 2 import jieba 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',\ 9 width = 1000, height = 700, background_color = 'white') 10 w.generate(txt) 11 w.to_file('新时代中国特色社会主义.png')


浙公网安备 33010602011771号