Commit 76532cae by BellCodeEditor

save project

parent af0790c2
Showing with 14 additions and 4 deletions

717 Bytes | W: | H:

200 KB | W: | H:

my_cloud.png
my_cloud.png
my_cloud.png
my_cloud.png
  • 2-up
  • Swipe
  • Onion skin
import wordcloud
w= wordcloud.WordCloud(background_color='white',font_path='SimHei.ttf')
w.generate('贝尔编程')
w.to_file('my_cloud.png')
\ No newline at end of file
from PIL import Image
import numpy
import jieba
with open('python二级考试大纲.txt',encoding='utf-8') as f:
text=f.read()
text_list = jieba.lcut('skjg gvdvgh, f沟沟壑壑关键还有个,离婚卡thjuhjtluhjtglhjutilhidujlhuhl8h8ntulhiutlhtuhlt6oujhop68hj6o')
text = ' '.join(text_list)
img = Image.open('bell.png')
data = numpy.array(img)
img_colors = wordcloud.ImageColorGenerator(data)
w= wordcloud.WordCloud(background_color='white',font_path='SimHei.ttf',mask=data,color_func=img_colors)#设置
w.generate(text)#文本转换成图片
w.to_file('my_cloud.png')
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