我不知道从哪里开始检索所有词典。
答案 0 :(得分:0)
您可以尝试这种方法:
gradebook=[{"name": "Samantha", "homework": 95, "test": 92, "exam": 100},{"name": "john", "homework": 55, "test": 11, "exam": 12},{"name": "shane", "homework": 5, "test": 1, "exam": 2}]
#if you want to access first student entire dict then
print(gradebook[0])
#if you want to access any student entire dict by name
name='john'
for i in gradebook:
for index_no,value in i.items():
if value==name:
print(i)
输出:
{'exam': 100, 'test': 92, 'name': 'Samantha', 'homework': 95}
{'exam': 12, 'test': 11, 'name': 'john', 'homework': 55}