ADD file via upload

master
Qyalifpq9 3 years ago
parent b449249b3e
commit b68c740f51

@ -0,0 +1,36 @@
# -*- codeing utf-8 -*-
# @Time :2021/11/613:48
# @Author :1900301218
# @File :picture.py
# @Software :PyCharm
from wordcloud import WordCloud
import cv2
import jieba
import matplotlib.pyplot as plt
with open('pythonworkinfo.txt', 'r') as f:
text = f.read()
cut_text = " ".join(jieba.cut(text))
color_mask = cv2.imread('hh.jpg')
cloud = WordCloud(
# 设置字体,不指定就会出现乱码
font_path=" C:\\Windows\\Fonts\\simsun.ttc",
# font_path=path.join(d,'simsun.ttc'),
# 设置背景色
background_color='white',
# 词云形状
mask=color_mask,
# 允许最大词汇
max_words=2000,
# 最大号字体
max_font_size=40
)
wCloud = cloud.generate(cut_text)
wCloud.to_file('cloud.jpg')
plt.imshow(wCloud, interpolation='bilinear')
plt.axis('off')
plt.show()
Loading…
Cancel
Save