I need pointers to parse an INI file using python 2.7 ConfigParser that looks like the following:
[google]
www.google.com domain_name=google location=external
[yahoo]
www.yahoo.com domain_name=yahoo location=external
This is what I have tried to do:
Config = ConfigParser.ConfigParser()
try:
Config.read("test.ini")
except Exception:
pass
options = Config.options('google')
for option in options:
print("Option is %s" % option)
print("Value for %s is %s" % (option, Config.get('google', option)))
And this is what the output is:
Option is www.google.com domain_name
Value for www.google.com domain_name is google location=external
I want to be able to parse www.google.com, and remaining key=value pairs(domain_name=google; location=external) in the same line for every section into a dictionary. Any pointers for this appreciated.