import json
record = '{"shirts":{"red":{"quantity":100},"blue":{"quantity":10}},"pants":{"black":{"quantity":50}}}'
inventory = json.loads(record)
for key, value in dict.items(inventory["shirts"]):
print key, value
for key, value in dict.items(inventory["pants"]):
print key, value
你不再有一个JSON对象,你有一个Pythondictionary。在字典上迭代产生它的键。
如果要访问这些值,请索引原始字典或使用返回不同内容的方法之一。
相关问题 更多 >
编程相关推荐