printing JSON values in Python -


I have searched articles through Googles and elsewhere, as well as read some related docs at docs.python .org and are still stuck.

I get feedback from the API below:

  {"status": "active", "perms": 1, "data": {"user_values ":" Delta ": - 203," value ": 53.32," command ": 42509}}}}  

I do not have 'status' or 'data' filtering Problems with the problem though, I can catch all of them that are the name of * user_values ​​*, not the date inside them.

It went on for a long time and was hoping someone could tell me in the right direction. New in Python and if I need to change this, how am I doing this because it is bad practices or the results of which I see are an easy way to get them, please tell me.

Code:

import json import urllib2 url = urllib2.urlopen ('http://URLofAPI.com') json_url = json. Load (url) api_result = json_url api_result for doc ['data'] ['40332895'] ['user_values']: Print Doctor

Output:
Delta
Price
order

I really want to get them (i.e.: '-203', '53.332 ',' 4250 9 ').

I'm basically trying to save that data in a list \ dict (different or different), then print it with other data. I have tried all kinds of things and can not manage it. I am sure it is probably something super easy that I am missing, but it is driving me crazy :)

Apart from this , I was really hoping to give me '42509' below, but I get an error:

  for api_result for doctor ['data'] ['40332895'] [ 'User_values'] ['command']  

Thanks advance!

You are asking the keys of the user_values ​​dictionary, and you are receiving them. Try this: ['user_values'] ['40332895'] UV = API_ ['data'] [print] UV [DOC]

for doctor in UV

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -