Commit 7c7a20b6 by BellCodeEditor

save project

parent 31180c0c
Showing with 7 additions and 2 deletions
import wordcloud import wordcloud
from PIL import Image from PIL import Image
import numpy as np import numpy as np
import jieba
img=Image.open('bell.png') img=Image.open('bell.png')
val=np.array(img) val=np.array(img)
img_colors=wordcloud.ImageColorGenerator(val) img_colors=wordcloud.ImageColorGenerator(val)
stopwords=['等','基本','程序','的']
w=wordcloud.WordCloud(background_color='black',font_path='SimHei.ttf',mask=val,color_func=img_colors) w=wordcloud.WordCloud(background_color='black',font_path='SimHei.ttf',mask=val,
color_func=img_colors,stopwords=stopwords,max_font_size=60)
with open(file='1.txt',mode='r',encoding='utf-8')as file: with open(file='1.txt',mode='r',encoding='utf-8')as file:
r=file.read() r=file.read()
l=jieba.lcut(r)
text="".join(l)
w.generate(r) w.generate(r)
w.to_file('py.png') w.to_file('py.png')
\ No newline at end of file

219 KB | W: | H:

220 KB | W: | H:

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