下载所需库
pip install matplotlib
pip install jieba
pip install wordcloud
代码实操:
import matplotlib.pyplot as plt
import jieba
from wordcloud import WordCloud
file = open('t.csv','r',encoding='utf-8').read()
csv_test = ''.join(jieba.lcut(file))
print(csv_test)
wc = WordCloud(
background_color='white',
font_path=r'C:\Windows\Fonts\simfang.ttf',
width=300,
height=300,
mode='RGBA',
).generate(csv_test)
plt.imshow(wc)
plt.axis('off')
plt.show()
wc.to_file('t.png')