上传文件至 /

This commit is contained in:
2026-06-23 11:13:00 +08:00
parent 7282f0159c
commit 5249ef528e
5 changed files with 148 additions and 0 deletions

19
q4_1.py Normal file
View File

@@ -0,0 +1,19 @@
import json
import matplotlib.pyplot as plt
with open("../q2_1_crawler/movies.json","r",encoding="utf-8") as f:
data = json.load(f)
movies = data["movies"]
genre_cnt = {}
for m in movies:
g = m["genre"]
genre_cnt[g] = genre_cnt.get(g,0)+1
x = list(genre_cnt.keys())
y = list(genre_cnt.values())
plt.bar(x,y)
plt.tight_layout()
plt.savefig("q4_1_bar.png",dpi=150)
plt.close()