上传文件至 /

This commit is contained in:
2026-03-31 11:22:15 +08:00
parent 118c9332aa
commit 490fd747cc
5 changed files with 151 additions and 0 deletions

18
26331,09test4.py Normal file
View File

@@ -0,0 +1,18 @@
import json
with open('movies.json', 'r', encoding='utf-8') as f:
movies = json.load(f)
total = sum(float(m['rating']) for m in movies)
average = total / len(movies)
print(f'Top10 电影平均分: {average:.2f}')
highest = max(movies, key=lambda m: float(m['rating']))
print(f'\n评分最高的电影:')
print(f" {highest['rank']}. {highest['title']} ({highest['en_title']})")
print(f" 评分: {highest['rating']}")
with_quote = [m for m in movies if m['quote']]
print(f'\n有经典台词的电影: {len(with_quote)}')
for m in with_quote:
print(f" \"{m['quote']}\" —— {m['title']}")