我有用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功能?