Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/327.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生成带有参数的GET请求JSON_Python_Json_Get - Fatal编程技术网

使用Python生成带有参数的GET请求JSON

使用Python生成带有参数的GET请求JSON,python,json,get,Python,Json,Get,我想知道如何使用两个查询参数对特定url发出GET请求?这些查询参数包含两个id号 到目前为止,我已经: import json, requests url = 'http://' requests.post(url) 但他们首先给了我查询参数,然后给了我最后一个查询参数。我不知道如何包含这些参数?要发出GET请求,您需要使用参数params参数: response = requests.get(url, params={'first_id': 1, 'last_id': 2}) 如果响应

我想知道如何使用两个查询参数对特定url发出GET请求?这些查询参数包含两个id号 到目前为止,我已经:

import json, requests
url = 'http://'
requests.post(url)

但他们首先给了我查询参数,然后给了我最后一个查询参数。我不知道如何包含这些参数?

要发出GET请求,您需要使用参数
params
参数:

response = requests.get(url, params={'first_id': 1, 'last_id': 2})

如果响应是JSON内容类型,则可以使用快捷方式方法将其加载到Python对象中:

data = response.json()
print(data)

谢谢你的回复!如何获取JSON响应本身的响应?抱歉这是我第一次执行GET RequestIt response.json?那么打印response.json?啊,我明白了!非常感谢。