使用到的库: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')
标签:jieba,特色,社会主义,wordcloud,词云,txt,绘制 From: https://www.cnblogs.com/T-2187803607/p/17147548.html