标签:tor txt encoding with open inf color ima mic wordcloud
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()
标签:tor txt encoding with open inf color ima mic wordcloud
原文地址:https://www.cnblogs.com/1234ip/p/14691556.html