我是Python的新手,我想遍历字典内列表中的字典(令人困惑,我知道)。
my_dict = {"John": [{"class": "math", "score": 100, "year": 2014}, {"class": "english", "score": 85, "year": 2015}],
"Timmy": [{"class": "math", "score": 87, "year": 2014}, {"class": "english", "score": 91, "year": 2015}],
"Sally":[{"class": "math", "score": 95, "year": 2014}]}
我需要创建一个包含学生姓名及其综合分数的新词典(Sally只有一个分数)。>>
输出看起来像:
new_dict = {"John": 185, "Timmy": 178, "Sally": 95}
任何帮助或指导将不胜感激!
我是Python的新手,我想遍历字典列表内的字典(我知道这很混乱)。 my_dict = {“ John”:[{“ class”:“ math”,“ score”:100,“ year”:2014},{“ class”:“ ...
使用字典理解: