Commit 35a35d50 by BellCodeEditor

auto save

parent 6b1fbc15
Showing with 24 additions and 2 deletions
1.png

244 KB

import wordcloud import wordcloud
\ No newline at end of file from PIL import Image
import numpy as np
import jieba
img=Image.open("bell.png")
print(img)
value=np.array(img)
img_colors=wordcloud.ImageColorGenerator(value)
with open("python二级考试大纲.txt","r",encoding="utf-8")as file:
read=file.read()
txt_list=jieba.lcut(read)
read="".join(txt_list)
k=["的","和","基本","程序","python"]
w=wordcloud.WordCloud(background_color="white",font_path="SimHei.ttf",mask=value,
color_func=img_colors,stopwords=k,max_font_size=60)
w.generate(read)
w.to_file("1.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