0
我有一個下面的JSON當前在一個字典中叫做returned_data-我想獲取帳戶ID,但它看起來好像沒有識別出比第二級更深的任何鍵。例如:嵌套的JSON不加載爲字典中的Keys
returned_data["command1"]["customers"]
工作
returned_data["command1"]["customers"]["acctid"]
不起作用。
returned_data["command1"]["customers"].keys()
不顯示任何鍵。
我需要做些什麼才能引用acctid?
{
"command1": {
"customers": [{
"city": "none",
"cust_id": 204567,
"name_first": "John",
"name_last": "Smith",
"zip": "39199",
"street_addr_1": "1 Bat St",
"phones": [
{"phone_number": "(01) 5555555",
"phone_type": "Mobile",
"phone_code": "C"
},
{"phone_number": "(01) 5555555",
"phone_type": "Home",
"phone_code": "E"
}
],
"email_addr": "[email protected]",
"acctid": 123456,
"state": "WA",
"add_user": "JR",
"country": "AUS",
"acct_type": "P",
}
],
"ref": "123456",
"result": 0
},
"header": {"src_sys_type": 2,
"ver": 1,
"result": 0}
}
'returned_data [「command1」] [「customers」]'是一個列表,而不是一個字典。這是足夠的,還是你需要知道如何在Python中使用列表? –
看起來我需要工作我對列表的知識 - 謝謝! – tororm