Word Cloud of "Breaking the Sky"

After deleting the original python3.8 and installing 3.7, I finally installed the third-party library of wordcloud and started word cloud production.

As soon as I mentioned the word cloud, I wanted to use it to count things that I usually didn't pay attention to, it's not easy to count, but it should be very interesting.

So, after drawing on the relevant information on the Internet, I wrote a program to make the word cloud of the novel "Broken Sky".

code show as below:


#Call the function library import wordcloud
import jieba
import imageio

#Call picture p = imageio.imread ("Dou break the sky.png")
#打开文件
f=open("斗破苍穹.txt","r",encoding="utf-8")
text = f.read()
words=jieba.lcut(text)
wordlist="".join(words)
w=wordcloud.WordCloud(width=700,height=1111,font_path="msyh.ttc",background_color="black",stopwords=excludes,max_words=100,mask=p)
w.generate(wordlist)
w.to_file("斗云.png")

f.close()

 

Guess you like

Origin www.cnblogs.com/wjcdd/p/12683499.html
sky