How can I get all the accountNumber
, name
and phoneNumber
to be printed separately in Json Response using Python
[{
"msg": "result",
"id": "testdata",
"result": [{
"accountNumber": "123456",
"name": "CHRISfarmece",
"phoneNumber": "2333455"
}, {
"accountNumber": "553222",
"name": "name1",
"phoneNumber": "123456"
}, {
"accountNumber": "34566",
"name": "name2",
"phoneNumber": "24567"
}]
}]
You can simply loop through the result value (it's a list) and store each value in separeted list like below:
data2 = {'accountNumber':[], 'name':[], 'phoneNumber':[]}
for x in data1[0]['result']:
for key, value in x.items():
data2[key].append(value)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.