Commit 032e7240 by BellCodeEditor

save project

parent 7744e9a1
Showing with 6 additions and 2 deletions
import wordcloud
from PIL import Image
import numpy
import jieba
with open('python二级考试大纲.txt','r',encoding='utf-8')as f:
n=f.read()
i=Image.open('1.jpg')
t_l=jieba.lcut(n)
n=' '.join(t_l)
stopwords=['的','python','和','基本','程序']
i=Image.open('bell.png')
i_c=numpy.array(i)
d=wordcloud.ImageColorGenerator(i_c)
print(i)
w=wordcloud.WordCloud(background_color='white',font_path='STXINGKA.TTF',mask=i_c,color_func=d)
w=wordcloud.WordCloud(background_color='white',font_path='STXINGKA.TTF',mask=i_c,color_func=d,stopwords=stopwords,max_font_size=60)
w.generate(n)
w.to_file('1.png')
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