import matplotlib
import wordcloud
import jieba
import imageio
mask=imageio.imread("201.png")
txt="life is short,you need python python"
w=wordcloud.WordCloud(background_color="black")#
w.generate(txt)
w.to_file("Cloud_English.png")
txt="每天中午12点半后打扫,一周4-5次,\
周六周日不用去。机房垃圾少,打扫简单。每月160元。"
w=wordcloud.WordCloud(width=1000,\
font_path="msyh.ttc",\
height=700,mask=mask)
#另外可设置词云的最大字体 最小字体和之间的间隔字体以及图案mask掩模,实际的mask只会保留导入图形的形状,背景仍然为黑色
#设置最多的词云数量max_words=15
# w.generate(" ".join(jieba.lcut(txt)))
w.to_file("Cloud_English.png")