西游记词云
作者:互联网
from wordcloud import WordCloud,ImageColorGenerator
import jieba
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
with open('西游记.txt','r',encoding='gb18030') as f1:
d=f1.read()
wl=jieba.cut(d,cut_all=False)
data=','.join(wl)
font='C:\Windows\Fonts\STXINGKA.TTF'
wc1=WordCloud(font_path=font).generate(data)
plt.imshow(wc1,interpolation='bilinear')
plt.axis('off')
plt.show()
标签:f1,plt,WordCloud,cut,词云,import,font,西游记 来源: https://www.cnblogs.com/1234ip/p/14691556.html