有了这两个请求,我如何将结果合并到一个变量中?
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)谢谢
发布于 2020-12-27 21:33:55
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'])items将包含来自每个响应的所有项目。
https://stackoverflow.com/questions/65466244
复制相似问题