インストールと使用のpythonワードクラウドwordcloudライブラリ200 309

インストールライブラリ

pip install wordcloud

インストールが少し遅くなります。外国の資源ステーションからダウンロードしてください。我慢して

ここに画像を挿入説明

Wordの雲の経験 - 英語版

import wordcloud

txt = 'live is short i use python'
wc = wordcloud.WordCloud()
wc.generate(txt)
wc.to_file('test.png')

Wordの雲の中国語版

「中華の間違いました

import wordcloud

txt = '人生苦短,我用python'
wc = wordcloud.WordCloud()
wc.generate(txt)
wc.to_file('test.png')

「フォントの指定

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')
公開された64元の記事 ウォンの賞賛1 ビュー801

おすすめ

転載: blog.csdn.net/whalecode/article/details/104743628