【发布时间】:2017-05-06 00:54:49
【问题描述】:
abc = {
"orders": [
{
"orderID": 5,
"cost": 10,
"sell": 15
},
{
"orderID": 6,
"cost": 8,
"sell": 12
},
{
"orderID": 7,
"cost": 15,
"sell": 26
}
]
}
for key, value in abc.items():
print (value["orderID"])
我正在尝试提取 orderID 值,但似乎无法完成这项工作。它应该回应 5,6,7
【问题讨论】:
-
首先打印
value,然后看看它返回了什么......
标签: python json loops dictionary iteration