我有用3.x版本编写的Python脚本,由于环境的限制,我需要在2.7中进行转换。Python 2.7 ConfigParser中的ExtendedInterpolation()
我设法重构大部分语法DIFS和模块导入,但我会在一行来到了,我不知道如何处理:
def readConfigFile(self, file):
config = ConfigParser.ConfigParser(interpolation = ConfigParser.ExtendedInterpolation())
config.optionxform = str
config.read(file)
**config = ConfigParser.ConfigParser(interpolation = ConfigParser.ExtendedInterpolation())**
我发现了一些参考这里( Python ConfigParser interpolation from foreign section),但我不知道如何取代(重构)。
的ConfigParser:
在2.7版:https://docs.python.org/2/library/configparser.html,但ExtendedInterpolation()不是在3.x版本本
所以我的问题,是否有任何方法来重构上面的代码在Python 2.7和零售n功能?