Error while using ConfigParser in Python code -
in python code, use lot of urls. so, need store urls in file , use them whenever need. i’m trying use configparser. example,
i store urls in following file named path.cfg :
[urls] path1 = "http://gstore.unm.edu/apps/epscor/search/collections.json?version=3&theme=climate" path2 = "http://gstore.unm.edu/apps/epscor/search/collection/%s/datasets.json?version=3" next program code,
import configparser import requests import webbrowser filepath = 'path.cfg' config = configparser.configparser() config.read(filepath) value = config.items('urls') url1 = value[0][1] # i.e., path1 r = requests.get(url1) could please tell me what’s mistake on last line of code?
thanks!
the problem url's start , end double quotes: ", causes problems requests.get().
solution: remove " path.cfg
[urls] path1 = http://gstore.unm.edu/apps/epscor/search/collections.json?version=3&theme=climate path2 = http://gstore.unm.edu/apps/epscor/search/collection/%s/datasets.json?version=3
Comments
Post a Comment