词云
# 必须要有这些库
# pip install matplotlib
# pip install wordcloud
# pip install scipy
# pip install pillow
# pip install imageio
import wordcloud
from imageio import imread
mask = imread(r"F:教师课程day 06 est7.png")
f = open(r'threekingdoms.txt', 'r', encoding='utf8')
data = f.read()
w = wordcloud.WordCloud(font_path=r'C:WindowsFontssimkai.ttf', mask=mask, width=1000, height=700,
background_color="white")
w.generate(data)
w.to_file('outfile.png')