How to loop through API call with requests in python -
i trying write script in python loop through list of lat/long coordinates , send each set through boundary api call. want write each individual api response.
import json import requests coords = ['lat1, long1','lat2, long2','lat3, long3'] x in coords: loc={'?contains':'x','&sets':'a_parameter'} response = requests.get('http://apicall.com/', params=loc) data = response.json() print data
i know not proper way syntax 'x' within api call, cannot find documentation of loop including requests api call.
i think want this:
for x in coords: loc={'?contains' : x , '&sets' : 'a_parameter'} ...
this references x
variable, not string 'x'
.
Comments
Post a Comment