Installation library
pip install wordcloud
Installation will be a little slow. Download from foreign resources station. Wait patiently
Word cloud Experience - English Version
import wordcloud
txt = 'live is short i use python'
wc = wordcloud.WordCloud()
wc.generate(txt)
wc.to_file('test.png')
Word cloud Chinese version
"Chinese be wrong
import wordcloud
txt = '人生苦短,我用python'
wc = wordcloud.WordCloud()
wc.generate(txt)
wc.to_file('test.png')
"Specify the font
import wordcloud
font_path = r'C:\Windows\Fonts\simhei.ttf'
txt = '人生 苦短,我用 python'
wc = wordcloud.WordCloud(font_path=font_path)
wc.generate(txt)
wc.to_file('test.png')