Commit ae26453c by BellCodeEditor

save project

parent dfe51279
This diff is collapsed. Click to expand it.
{"code":0,"data":[],"success":true,"timestamp":1498654615930}
\ No newline at end of file
import wordcloud
from PIL import Image
import numpy
import json
import jieba
with open('python二级考试大纲.txt',encoding="utf-8") as f:
text=f.read()
img=Image.open('duck.png')
date=numpy.array(img)
imgcolor=wordcloud.ImageColorGenerator(date)
wordcloud.wordCloud(background_color="black",font_path="SimHef.ttf",mask=date)
w.generate(text)
w.to_fill('wordcloud.png')
a=jieba.lcut(text)
b=" ".join(a)
img=Image.open('bell.png')
data=numpy.array(img)
stopwords=["的","python","和","基本","程序"]
imgcolor=wordcloud.ImageColorGenerator(data)
w=wordcloud.WordCloud(background_color="black",font_path="SimHef.ttf",mask=data,color_func=imgcolor,stopwords=stopwords,max_font_size=60)
w.generate(b)
w.to_fill('wycloud.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