From 6f60fb8a05634b8354f03ca0ceb8d3dcfa9de25f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E9=9B=85=E9=9B=AF?= <2509165021@student.example.com> Date: Sun, 5 Jul 2026 16:04:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20q2=5F1=5Fcrawler/zhifang?= =?UTF-8?q?=5Frating.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- q2_1_crawler/zhifang_rating.py | 42 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/q2_1_crawler/zhifang_rating.py b/q2_1_crawler/zhifang_rating.py index ffde26d..dd0e9c7 100644 --- a/q2_1_crawler/zhifang_rating.py +++ b/q2_1_crawler/zhifang_rating.py @@ -1,21 +1,21 @@ -import matplotlib.pyplot as plt -import json - -rating=[] - -with open('movie.json', 'r', encoding='utf-8') as f: - data=json.load(f) - # print(data) - for i in data: - rating.append(i["rating"]) - -plt.figure(figsize=(12,8)) -plt.hist(rating, # 数据 - bins=10, # 分成几个柱子 - color='#3498DB', # 颜色 - edgecolor='white') # 柱子边框颜色 -plt.title('评分分布', fontsize=14) -plt.xlabel('评分', fontsize=13) -plt.grid(True, linestyle='--', alpha=0.5, axis='y') -plt.show() -plt.savefig("q4_3a_hist.png",dpi=150,format='png') \ No newline at end of file +import matplotlib.pyplot as plt +import json + +rating=[] + +with open('movie.json', 'r', encoding='utf-8') as f: + data=json.load(f) + # print(data) + for i in data: + rating.append(i["rating"]) + +plt.figure(figsize=(12,8)) +plt.hist(rating, # 数据 + bins=10, # 分成几个柱子 + color='#3498DB', # 颜色 + edgecolor='white') # 柱子边框颜色 +plt.title('评分分布', fontsize=14) +plt.xlabel('评分', fontsize=13) +plt.grid(True, linestyle='--', alpha=0.5, axis='y') +plt.savefig("q4_3a_hist.png",dpi=150,format='png') +plt.show()