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

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -