Reputation: 63
I am receiving a python dict that has the following format via curl.
json = connect(header, URL)
I am trying to iterate/get the different "number" values with the following code:
for i in json['mail']['number']:
print (str(i).replace('"',''))
but it does not work. Any ideas?
Upvotes: 0
Views: 25
Reputation: 1033
You're iterating over the wrong object, try this:
for i in json['mail']:
print(int(i['number']))
Please also note: naming a variable json
could be very bad because most likely you are using the json
package as well and this will lead to naming conflicts.
Upvotes: 1