From 5d5283d8e0a0cfb2d8e1f1d4b876df7952be1372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=A5=A0=E6=A5=A0?= <2509165032@student.example.com> Date: Tue, 23 Jun 2026 11:13:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20q4/q4=5F1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- q4/q4_1/q4_1.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 q4/q4_1/q4_1.py diff --git a/q4/q4_1/q4_1.py b/q4/q4_1/q4_1.py new file mode 100644 index 0000000..aed5034 --- /dev/null +++ b/q4/q4_1/q4_1.py @@ -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() \ No newline at end of file