使用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'])