Commit 93642e58 by BellCodeEditor

save project

parent 03f85441
Showing with 14 additions and 4 deletions

64.4 KB | W: | H:

74.5 KB | W: | H:

moiy.png
moiy.png
moiy.png
moiy.png
  • 2-up
  • Swipe
  • Onion skin
import wordcloud
from PIL import Image
import numpy as np
import jieba
with open('python二级考试大纲.txt','r',encoding= 'utf-8') as t:
d = t.read()
w = wordcloud.WordCloud(background_color='blue',font_path='SimHei.ttf')
w.generate(d)
w.to_file('moiy.png')
\ No newline at end of file
f=jieba.lcut(d)
f1 = ' '.join(f)
igm=Image.open('bell.png')
av = np.array(igm)
igm_clor= wordcloud.ImageColorGenerator(av)
stops = ['的','定义','索引','必选']
w = wordcloud.WordCloud(background_color='white',font_path='SimHei.ttf',
mask=av,color_func=igm_clor,stopwords=stops,max_font_size=60)
w.generate(f1)
w.to_file('xbell.png')
\ No newline at end of file
xbell.png

208 KB

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