ConfigParser中sections下的options区分大小写

使用ConfigParser时发现在sections下面的options不会区分大小写,原因为ConfigParser设置默认为识别小写,自己从新改下optionxform即可

class MyConfigParser(ConfigParser.ConfigParser):
    """
    set ConfigParser options for case sensitive.
    """
    def __init__(self, defaults=None):
        ConfigParser.ConfigParser.__init__(self, defaults=defaults)
 
    def optionxform(self, optionstr):
        return optionstr

 

你可能感兴趣的:(python)