2 回答

TA貢獻(xiàn)1831條經(jīng)驗(yàn) 獲得超4個(gè)贊
sids = [123, 1234]
api_uri = "https://localhost:8080?sid={}"
response = []
for sid in sids:
response = request.get(api_uri.format(sid))
responses.append(response.json[0])
然后將其添加到文件中
import json
with open(<filename>) as file_handler:
json.dump(responses, file_handler, indent=2)

TA貢獻(xiàn)1815條經(jīng)驗(yàn) 獲得超10個(gè)贊
這應(yīng)該對(duì)你有用
my_api_urls= ["https://localhost:8080?sid=123", "https://localhost:8080?sid=1234"]
responses=[]
for i in my_api_urls:
responses.append(requests.get(i).json()[0])
添加回答
舉報(bào)