Commit 21835aaf by BellCodeEditor

save project

parent f40c7234
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:
d=f.read()
e=jieba.lcut(d)
d=" ".join(e)
b=Image.open("bell.png")
c=numpy.array(b)
img_colors=wordcloud.ImageColorGenerator(c)
w=wordcloud.WordCloud(background_color="red",font_path="SimHei.ttf",mask=c,color_func=img_colors)
stopwords=["的","和","基本","程序"]
w=wordcloud.WordCloud(background_color="red",font_path="SimHei.ttf",mask=c,color_func=img_colors,stopwords=stopwords,max_font_size=60)
w.generate(d)
w.to_file("word.png")
\ No newline at end of file

219 KB | W: | H:

239 KB | W: | H:

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