The code snippet below can edit an ini file, but will replace all ini entries to lower case:
config = ConfigParser.RawConfigParser()
config.read("test.ini")
config.set("GENERAL", "OptionEntry4", "100")
with open("test.ini", 'w') as configfile:
config.write(configfile)
according to the documentation : "All option names are passed through the optionxform() method. Its default implementation converts option names to lower case."
config = ConfigParser.RawConfigParser()
config.optionxform = str
should fix it.
config = ConfigParser.RawConfigParser()
config.optionxform = str
config.read("test.ini")
config.set("GENERAL", "OptionEntry4", "100")
with open("test.ini", 'w') as configfile:
config.write(configfile)
Read the doc: https://docs.python.org/2/library/configparser.html#ConfigParser.RawConfigParser.optionxform
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.