This question already has an answer here:
这个问题在这里已有答案:
- Access a particular field in arbitrarily nested JSON data 3 answers
在任意嵌套的JSON数据3答案中访问特定字段
I am trying to extract data from JSON Object which is returned from the api call for api.trends() [Tweepy] but I am not able to extract the data.
我试图从api调用api.trends()[Tweepy]返回的JSON对象中提取数据,但我无法提取数据。
Can anyone give me an example of how to extract data from JSON object. I want to extract the data in tabular form.
任何人都可以给我一个如何从JSON对象中提取数据的示例。我想以表格形式提取数据。
Thanks in advance.
提前致谢。
1 个解决方案
#1
10
Once you run it though json.loads()
it becomes normal Python objects. Simply index it as you would any dict or list.
一旦你通过json.loads()运行它就会成为普通的Python对象。只需将其编入索引,就像任何字典或列表一样。
>>> json.loads('{"foo": 42, "bar": "baz"}')[u'bar']
u'baz'
#1
10
Once you run it though json.loads()
it becomes normal Python objects. Simply index it as you would any dict or list.
一旦你通过json.loads()运行它就会成为普通的Python对象。只需将其编入索引,就像任何字典或列表一样。
>>> json.loads('{"foo": 42, "bar": "baz"}')[u'bar']
u'baz'