读取conf
2019-07-12 本文已影响0人
IBM_LELE
Conf 编码
一.ANSI
#获取config配置文件
def getConfig(section, key):
config = configparser.ConfigParser()
path = os.path.split(os.path.realpath(__file__))[0] + '/app.conf'
# config.read(path,encoding='UTF-8')
config.read(path)
return config.get(section, key)
# 写config配置文件
def writeConfig(section, key,newvalue):
config = configparser.ConfigParser()
path = os.path.split(os.path.realpath(__file__))[0] + '/app.conf'
# config.read(path,encoding='UTF-8')
config.read(path)
config.set(section,key,newvalue)
config.write(open(path,"r+"))
二.UTF-8
读取conf 时, 多出了 conf '\ufeff[api] 。