Commit ccbda317 by BellCodeEditor

save project

parent 0788c71d
Showing with 6 additions and 3 deletions
import wordcloud
from PIL import Image
import jieba
import numpy
with open('python二级考试大纲.txt',encoding='utf-8')as f:
b=f.read()
img =Image.open("bell.png")
d=numpy.array(img)
t=jieba.lcut(b)
b="".join(t)
img_colors=wordcloud.ImageColorGenerator(d)
stopwords=["的","python","和","基本","程序"]
w=wordcloud.WordCloud(background_color="white",font_path='SimHei.ttf',mask=d,color_func=img_colors,scale=50)
w=wordcloud.WordCloud(background_color="white",font_path='SimHei.ttf',mask=d,color_func=img_colors,scale=10,
stopwords=stopwords,max_font_size=60)
w.generate(b)
w.to_file("sb.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