Commit 003338c6 by BellCodeEditor

save project

parent 5cbd6170
Showing with 1 additions and 6 deletions
import wordcloud import wordcloud
from PIL import Image from PIL import Image
import numpy as np import numpy as np
import jieba
img=Image.open('bell.png') img=Image.open('bell.png')
data=np.array(img) data=np.array(img)
stopword=['的','python','和'] w=wordcloud.WordCloud(background_color='white',font_path='SimHei.ttf',width=1920,height=1080,mask=data,color_func=wordcloud.ImageColorGenerator(data))
with open('python二级考试大纲.txt','r',encoding='utf-8') as z: with open('python二级考试大纲.txt','r',encoding='utf-8') as z:
txt=z.read() txt=z.read()
jbtxt=jieba.lcut(txt)
text= " ".join(jbtxt)
w=wordcloud.WordCloud(background_color='white',font_path='SimHei.ttf',width=1920,height=1080,mask=data,color_func=wordcloud.ImageColorGenerator(data),stopwords=stopword,max_font_size=60)
w.generate(txt) w.generate(txt)
w.to_file('pic1.png') w.to_file('pic1.png')
\ No newline at end of file

208 KB | W: | H:

184 KB | W: | H:

pic1.png
pic1.png
pic1.png
pic1.png
  • 2-up
  • Swipe
  • Onion skin
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment