从Json收集一个值
这个问题在这里已经有了答案:
用json
模块解码后,这只是一个包含列表和字符串以及其他字典的字典:
import json
json_result = json.loads(json_string)
id = json_result['data'][0]['id']
演示:
>>> import json
>>> sample = '''
... {
... "status": "success",
... "data": [
... {
... "notes": [],
... "handles": {
... "twitter": [
... {
... "networkinstance": "twitter",
... "Uid": "fefewf32ff32f232f3f",
... "id": "243425324242",
... "@class": "Provider"
... }
... ]
... },
... "id": "g43g5434g43f2f3",
... "tags": []
... }
... ]
... }
... '''
>>> json_result = json.loads(sample)
>>> json_result['data'][0]['id']
u'g43g5434g43f2f3'
链接地址: http://www.djcxy.com/p/38047.html