我想将 Tweepyapi.trends_location(woeid)
调用的结果转换为 dict(或 dicts 的 dict),这样我就可以使用这些值(真的,我想最终得到一个 'name' 值的 dict)。Tweepy 文档说结果是“一个 JSON 对象”(见这里),但是当我检索它时,type(retrieved)
计算结果为list
. 果然,retrieved
有一个len
1的,retrieved[0]
给我一个单品:
[{'trends': [{'url': 'http://search.twitter.com/search?q=%23questionsidontlike', 'query': '%23questionsidontlike', 'events': None, 'promoted_content': None, 'name': '#questionsidontlike'}, ], (more of the same), 'created_at': '2011-01-31T22:39:16Z', 'as_of': '2011-01-31T22:47:47Z', 'locations': [{'woeid': 23424977, 'name': 'United States'}]}]
。
我可以调用json.dumps
,这将提供格式良好的表示,但这对我来说没有多大用处,并json.loads
给了我:__init__() got an unexpected keyword argument 'sort_keys'
我应该如何进行?