mirror of
https://github.com/WMK965/965-Python-Learning-Repo.git
synced 2025-06-16 17:18:30 +00:00
添加练习内容(词云)
This commit is contained in:
parent
c053919887
commit
9f9301876c
@ -67,7 +67,7 @@ import matplotlib.pyplot as plt
|
|||||||
plt.rcParams['font.sans-serif'] = ['SimHei']
|
plt.rcParams['font.sans-serif'] = ['SimHei']
|
||||||
plt.rcParams['axes.unicode_minus'] = False
|
plt.rcParams['axes.unicode_minus'] = False
|
||||||
|
|
||||||
A1 = np.loadtxt('ex3.csv', dtype=str, delimiter=',')
|
A1 = np.loadtxt('./resources/ex3.csv', dtype=str, delimiter=',')
|
||||||
month = np.array(A1[:, 0][1:13])
|
month = np.array(A1[:, 0][1:13])
|
||||||
n1_data = [eval(x) for x in A1[:, 1][1:13]]
|
n1_data = [eval(x) for x in A1[:, 1][1:13]]
|
||||||
n2_data = [eval(x) for x in A1[:, 2][1:13]]
|
n2_data = [eval(x) for x in A1[:, 2][1:13]]
|
||||||
|
BIN
results/111.png
BIN
results/111.png
Binary file not shown.
Before Width: | Height: | Size: 297 KiB After Width: | Height: | Size: 297 KiB |
4
temp.py
4
temp.py
@ -4,10 +4,10 @@ from PIL import Image
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
raw_data = open("111.txt", encoding="gbk").read()
|
raw_data = open("./resources/111.txt", encoding="gbk").read()
|
||||||
ls = jieba.lcut(raw_data)
|
ls = jieba.lcut(raw_data)
|
||||||
text = ' '.join(ls)
|
text = ' '.join(ls)
|
||||||
open("111.txt", encoding="gbk").close()
|
open("./resources/111.txt", encoding="gbk").close()
|
||||||
mask = np.array(Image.open("./resources/mask.png"))
|
mask = np.array(Image.open("./resources/mask.png"))
|
||||||
wc = wordcloud.WordCloud(font_path="msyh.ttc",
|
wc = wordcloud.WordCloud(font_path="msyh.ttc",
|
||||||
mask=mask,
|
mask=mask,
|
||||||
|
Loading…
Reference in New Issue
Block a user