【发布时间】:2019-03-09 06:14:22
【问题描述】:
我的问题如下:我有一个在 nparray (ip_array) 中排序的 Ips 列表,然后我想对所有这些请求执行多个请求并将输出保存在单个 json 中。 (APIKEY其实就是代码xD中的api key)
url_auth = 'https://api.ipgeolocation.io/ipgeo?apiKey=APIKEYAPIKEYAPIKEY='
for i in np.arange(1,4):
r[i] = requests.request(method='get',url=url_auth,params={'ips':ip_array[i]}) #i tested the single request and it works in this way.
然后,我明白了
TypeError: 'Response' object does not support item assignment
然后,我尝试用
替换最后一行 r = requests.request(method='get',url=url_auth,params={'ips':ip_array[i]})
但是,当我这样做时
r.json()
我只收到最后一个请求(这很明显)。
【问题讨论】:
标签: python json api python-requests jupyter