Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/311.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合并requests.get_Python_Merge_Get_Request - Fatal编程技术网

使用python合并requests.get

使用python合并requests.get,python,merge,get,request,Python,Merge,Get,Request,有了这两个请求,如何将结果合并到一个变量中 listone=requests.get(URL + API_URL + endpoint, headers=API_HEADER, params=getparams) #some missing code that do stuff listtwo=requests.get(URL + API_URL + endpoint,

有了这两个请求,如何将结果合并到一个变量中

listone=requests.get(URL + API_URL + endpoint,
                            headers=API_HEADER,
                            params=getparams)

#some missing code that do stuff


listtwo=requests.get(URL + API_URL + endpoint,
                            headers=API_HEADER,
                            params=getparams)
谢谢

项目将包含每个响应中的所有项目

url_header_list = [
    (url1, headers1),
    (url2, headers2),
]

items = []
# You can change your headers and url in any way you want, not just like that
for url, headers in url_header_list:
    # And this you need to do for each pair of url and headers
    response = requests.get(url, headers=headers).json()
    items.extend(response['items'])