美文网首页
读取conf

读取conf

作者: IBM_LELE | 来源:发表于2019-07-12 10:51 被阅读0次

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] 。

相关文章

网友评论

      本文标题:读取conf

      本文链接:https://www.haomeiwen.com/subject/cmqoqctx.html