Commit 20ff5142 by BellCodeEditor

save project

parent ba14cd77
Showing with 18 additions and 3 deletions
import wordcloud import wordcloud
w = wordcloud.word(background_color="white") from PIL import Image
w.generate() import numpy
\ No newline at end of file import jieba
with open('python二级考试大纲.txt',encoding='utf-8') as f:
text = f.read()
txt_list = jieba.lcut(text)
text = "".join(txt_list)
img = Image.open("bel.png")
data = numpy.array(img)
img_colors = wordcloid.ImageColorGenerator(data)
w = wordcloud.WordCloud(background_colour="white",
font_path='SimHei.ttf',
mask=data,color_func=img_colors,
stopwords=stopwords, max_font_size=60)
w.generate(text)
w.ot.file("mycloud.png")
\ No newline at end of file
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