Commit 691bf968 by BellCodeEditor

auto save

parent 93b8c85c
Showing with 20 additions and 2 deletions

209 KB | W: | H:

211 KB | W: | H:

cloud.png
cloud.png
cloud.png
cloud.png
  • 2-up
  • Swipe
  • Onion skin
import wordcloud
\ No newline at end of file
import wordcloud
from PIL import Image
import numpy
import jieba
with open("python二级考试大纲.txt",'r',encoding='utf-8') as word:
text = word.read()
text_list = jieba.lcut(text)
sentence = " ".join(text_list)
stop = ["必选","基本的","定义","的","间","不","分","和","基本"]
image = Image.open('bell.png')
data = numpy.array(image)
img_colors = wordcloud.ImageColorGenerator(data)
w = wordcloud.WordCloud(background_color='white',
font_path='SimHei.ttf',
mask=data,color_func=img_colors
,stopwords=stop,max_font_size=60)
w.generate(sentence)
w.to_file("cloud.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