在di中查找项目

2024-04-27 03:01:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我希望从下面的值中获得student_id的值,但我不确定如何获得,因为该值位于嵌套的dict中。我怎么去student_id

{
    "specification": {
        "[student_id]": {
            "grade_level": "numeric grade level between 1 and 6",
            "score": "Test score, numeric, between 1 and 4",
            "school_id": "school id"
        }
    },
    "data": {
        "1": {
            "grade_level": 1,
            "score": 3,
            "school_id": "PS0001"
        },
        "2": {
            "grade_level": 1,
            "score": 4,
            "school_id": "PS0001"
        }
    }
}

到目前为止我已经试过了

['specification'].keys()

Tags: andtestiddatabetweenkeyslevelstudent