數據獲取:
鏈接:https://pan.baidu.com/s/1-OV41OlDnNgBJyMvHF2Z1Q?pwd=6666
提取碼:6666
目錄結構:
代碼如下:
import jieba
import wordcloud
f = open("data.txt", "r", encoding='utf-8')
t = f.read()
f.close()
ls = jieba.lcut(t)
txt = " ".join(ls)
w = wordcloud.WordCloud(
width=1000, height=700,
background_color="white",
font_path="msyh.ttc"
)
w.generate(txt)
w.to_file("grwordcloud.png")
print('詞雲繪製完成!')
效果圖: