Commit 9d9b004f by BellCodeEditor

save project

parent 25d3f59e
Showing with 7 additions and 2 deletions
import wordcloud import wordcloud
import numpy as np import numpy as np
from PIL import Image from PIL import Image
import jieba
f=open('python二级考试大纲.txt','r',encoding='utf-8') f=open('python二级考试大纲.txt','r',encoding='utf-8')
n=f.read() n=f.read()
l1=jieba.lcut(n)
l=' '.join(l1)
i=Image.open('bell.png') i=Image.open('bell.png')
v=np.array(i) v=np.array(i)
d=wordcloud.ImageColorGenerator(v) d=wordcloud.ImageColorGenerator(v)
w=wordcloud.WordCloud(background_color='skyblue',font_path='STXINWEI.TTF',mask=v,color_func=d) sssss=['的','python','和','基本','程序']
w.generate(n) w=wordcloud.WordCloud(background_color='skyblue',font_path='STXINWEI.TTF',mask=v,color_func=d,stopwords=sssss,max_font_size=60)
w.generate(l)
w.to_file('sb.png') w.to_file('sb.png')
f.close() f.close()
\ No newline at end of file

176 KB | W: | H:

200 KB | W: | H:

sb.png
sb.png
sb.png
sb.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