5
我想解析一個json對象並有問題。如何使用python解析json-object?
import json
record= '{"shirt":{"red":{"quanitity":100},"blue":{"quantity":10}},"pants":{"black":{"quantity":50}}}'
inventory = json.loads(record)
#HELP NEEDED HERE
for item in inventory:
print item
我可以弄清楚如何獲取這些值。我可以拿鑰匙。請幫忙。
如果你能得到鑰匙,那麼你肯定能得到的值。該示例顯示了一個嵌套字典。循環瀏覽它,在顯示之前檢查它是否是字典 –
我想我明白了。 – nebulus