You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
985 B
36 lines
985 B
2 years ago
|
import washer,contentout
|
||
|
contentout.start()
|
||
|
with open('content.txt', 'r+', encoding='utf-8') as f:
|
||
|
content = f.read()
|
||
|
message = washer.process(content)
|
||
|
author = []
|
||
|
favor = {}
|
||
|
print(message)
|
||
|
for video in message:
|
||
|
if video[2] not in author:
|
||
|
author.append(video[2])
|
||
|
favor[video[2]] = eval(video[3])
|
||
|
elif video[2] in author:
|
||
|
favor[video[2]] += eval(video[3])
|
||
|
import matplotlib.pyplot as plt
|
||
|
# 用黑体显示中文
|
||
|
plt.rcParams['font.sans-serif'] = ['SimHei']
|
||
|
plt.rcParams['figure.figsize'] = (10, 5) # 设置figure_size尺寸
|
||
|
|
||
|
# 绘制柱状图
|
||
|
plt.bar(favor.keys(), favor.values())
|
||
|
plt.xlabel("作者",fontsize=14)
|
||
|
plt.ylabel("点赞数目",fontsize=14)
|
||
|
# 每个扇形的标签
|
||
|
labels = favor.keys()
|
||
|
# 每个扇形的占比
|
||
|
sizes = favor.values()
|
||
|
|
||
|
fig1, ax1 = plt.subplots()
|
||
|
# 绘制饼图
|
||
|
ax1.pie(sizes, labels=labels, autopct='%d%%',radius=1,textprops={'fontsize': 10}, startangle=90)
|
||
|
|
||
|
ax1.axis()
|
||
|
plt.show()
|
||
|
|