Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python instagram中解析JSON_Python_Json - Fatal编程技术网

在python instagram中解析JSON

在python instagram中解析JSON,python,json,Python,Json,以下是我从instagram得到的回复: {"data": {"id": "###########", "bio": "Some text", "full_name": "Full Name", "profile_picture": "https://something.jpg", "website": "", "username": "username", "counts": {"followed_by": 139, "media": 38, "follows": 374}}, "meta":

以下是我从instagram得到的回复:

{"data": {"id": "###########", "bio": "Some text", "full_name": "Full Name", "profile_picture": "https://something.jpg", "website": "", "username": "username", "counts": {"followed_by": 139, "media": 38, "follows": 374}}, "meta": {"code": 200}}
我想得到后面的数字,所以我想我会使用:

var["data"]["counts"]["followed_by"]
但是,这给了我一个错误:

indices must be integers
我做错了什么?我应该用吗

for key, values in var.interitems:

您需要首先解析JSON。以下是使用您的数据的工作示例:

import json
response_text = """{"data": {"id": "###########", "bio": "Some text", "full_name": "Full Name", "profile_picture": "https://something.jpg", "website": "", "username": "username", "counts": {"followed_by": 139, "media": 38, "follows": 374}}, "meta": {"code": 200}}"""
response_dict = json.loads(response_text)
print response_dict["data"]["counts"]["followed_by"]

响应可能是像您提供的那样的对象列表吗?