How do I put a semicolon in a value in python configparser?
Python - 2.7
I have a python config parser with a section where the Key is a url and the value is a token. The key being a url contains :, -, ? and various other chars same applies to value. As you can see from the above question the special chars in the value section seems to be fine but the key does not appear to be fine.
Is there anything I can do about this? My alternatives are resolving to a json file and manually writing/reading it manually.
For example if you run the below program once I get
cp = ConfigParser.ConfigParser()
cp.add_section("section")
cp.set("section", "http://myhost.com:9090", "user:id:token")
cp.set("section", "key2", "value2")
with open(os.path.expanduser("~/test.ini"), "w") as f:
cp.write(f)
cp = ConfigParser.ConfigParser()
cp.read(os.path.expanduser("~/test.ini"))
print cp.get("section", "key2")
print cp.get("section", "http://myhost.com:9090")
the file looks like below
[section]
http://myhost.com:9090 = user:id:token
key2 = value2
And I get exceptions ConfigParser.NoOptionError: No option 'http://myhost.com:9090' in section: 'section'