Commit 77c9b020 by BellCodeEditor

save project

parent ceee78cb
Showing with 6 additions and 2 deletions
import wordcloud
from PIL import Image
import numpy as np
import jieba
img = Image.open("bell.png")
val = np.array(img)
img_colors = wordcloud.ImageColorGenerator(val)
w = wordcloud.WordCloud(background_color="white" , font_path="SimHei.ttf",mask=val ,color_func=img_colors)
stopwords = ["的","基本","程序"]
w = wordcloud.WordCloud(background_color="white" , 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:
r = file.read()
l = jieba.lcut(r)
text = " ".join(l)
w.generate(r)
w.to_file("py.png")
\ No newline at end of file

215 KB | W: | H:

213 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