python:ConfigParser把大写字母转成了小写字母 | ConfigParser reads capital keys and make them lower case

source:http://stackoverflow.com/questions/19359556/configparser-reads-capital-keys-and-make-them-lower-case

ConfigParser.ConfigParser() is a subclass of ConfigParser.RawConfigParser(), which is documented to behave this way:

All option names are passed through the optionxform() method. Its default implementation converts option names to lower case.

That’s because this module parses Windows INI files which are expected to be parsed case-insensitively.

You can disable this behaviour by replacing the RawConfigParser.optionxform() function:

str passes through the options unchanged.

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注