上传文件至 /

This commit is contained in:
2026-06-23 11:12:36 +08:00
parent 16397e49cd
commit 3e821217d2
3 changed files with 70 additions and 0 deletions

26
data_analysis.py Normal file
View File

@@ -0,0 +1,26 @@
import json
read_file = open("movies.json", "r", encoding="utf-8")
movie_data = json.load(read_file)
read_file.close()
rank_movie = sorted(movie_data, key=lambda x: x["rating"])
min_score_movie = rank_movie[0]
max_score_movie = rank_movie[-1]
print("1、评分最低电影", min_score_movie["title"], ",评分:", min_score_movie["rating"])
print(" 评分最高电影:", max_score_movie["title"], ",评分:", max_score_movie["rating"])
genre_count_dict = {}
for film in movie_data:
film_type = film["genre"]
if film_type in genre_count_dict:
genre_count_dict[film_type] = genre_count_dict[film_type] + 1
else:
genre_count_dict[film_type] = 1
print("\n2、各类型电影统计", genre_count_dict)
director_count_dict = {}
for film in movie_data:
dir_name = film["director"]
if dir_name in director_count_dict:
director_count_dict[dir_name] += 1
else:
director_count_dict[dir_name] = 1
print("\n3、各导演电影数量", director_count_dict)
count_after_2020 = 0