您可以创建子类并更改.write方法,以从以下位置的两侧删除空格
=:
import ConfigParserimport osclass MyConfigParser(ConfigParser.ConfigParser): def write(self, fp): """Write an .ini-format representation of the configuration state.""" if self._defaults: fp.write("[%s]n" % ConfigParser.DEFAULTSECT) for (key, value) in self._defaults.items(): fp.write("%s=%sn" % (key, str(value).replace('n', 'nt'))) fp.write("n") for section in self._sections: fp.write("[%s]n" % section) for (key, value) in self._sections[section].items(): if key == "__name__": continue if (value is not None) or (self._optcre == self.OPTCRE): key = "=".join((key, str(value).replace('n', 'nt'))) fp.write("%sn" % key) fp.write("n")config = MyConfigParser().....
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)