Parsing nested JSON response Python
This question already has an answer here:
You can use the keys method in the dictionary object to fetch the keys and then iterate over to get the required value.
Example:
d = {
"available_projects": {
"model001": {
"available_models": [
"model_20171004-090552"
],
"status": "ready"
},
"model002": {
"available_models": [
"model_20171013-143108"
],
"status": "ready"
},
"model002b": {
"available_models": [
"model_20171013-151458"
],
"status": "ready"
}
}
}
for i in d["available_projects"].keys():
print i, "=" , d["available_projects"][i]['available_models'][0]
Output:
model001 = model_20171004-090552
model002b = model_20171013-151458
model002 = model_20171013-143108
链接地址: http://www.djcxy.com/p/30378.html
上一篇: KeyError循环每个键的多个值
下一篇: 解析嵌套的JSON响应Python