Python 需要获取字典,该字典是其他字典的列表

Python 需要获取字典,该字典是其他字典的列表,python,python-3.x,dictionary,Python,Python 3.x,Dictionary,我不知道从哪里开始检索所有词典。您可以尝试以下方法: 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

我不知道从哪里开始检索所有词典。

您可以尝试以下方法:

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}

你有一份字典的清单。字典是Python对象。如果要提取这些对象中的第一个,则将访问列表第一个位置的对象。通过,
成绩册[0]
可能重复的