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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -