import jsonpathdic = { " error_code " : 0, " stu_info " : [ { " id " : 2057 , " name " : " xiaohei " , " sex " : " nan " , " age " : 29 , " addr " : " beijing " , " grade " : " tianxie " , " phone " : " 18712321234 " , " gold " : 100 } ]}s
import jsonpath dic={ "error_code": 0, "stu_info": [ { "id": 2057, "name": "xiaohei", "sex": "nan", "age": 29, "addr": "beijing", "grade": "tianxie", "phone": "18712321234", "gold": 100 } ] } s=jsonpath.jsonpath(dic,‘$..age‘) s2=jsonpath.jsonpath(dic,‘$..error_code‘) s3=jsonpath.jsonpath(dic,‘$..abc‘) print(s) print(s2) print(s3) #如果取到的值不存在就返回False