Python——制作中文词云

from os import path
from wordcloud import WordCloud

wc = WordCloud(
    background_color="white", #背景颜色
    max_words=200, #显示最大词数
    font_path='./fonts/simhei.ttf'
    )
cloud_text = open(path.join('2.txt')).read()
wc.generate(cloud_text)
wc.to_file("pic2.png")

注意:制作中文词云时,请添加 font_path='./fonts/simhei.ttf'

你可能感兴趣的:(Python)