python词云
import jieba
import numpy as np
from PIL import Image
from wordcloud import WordCloud
ci_str = "你想要产生词云的句子"
ci_list = jieba.lcut(ci_str) # 将字符串分成词云列表
print(ci_list)
ci_str = " ".join(ci_list) # 变成字符串
print(ci_str)
mask = np.array(Image.open("timg.png")) # 产生词云形状 (最好使用白色背景图片)
ci_cloud = WordCloud(font_path="msyh.ttc", background_color="white", mask=mask).generate(ci_str)
ci_cloud.to_file("ci.png") # 保存所产生的词云