python 使用中遇到的问题,记录及解决方法

1、读取configparser 配置文件报错   :

提示:

 ConfigParser.MissingSectionHeaderError when parsing rsyncd config file with global options

解决方法:

https://stackoverflow.com/questions/22501121/configparser-missingsectionheadererror-when-parsing-rsyncd-config-file-with-glob

cfg = configparser.ConfigParser()
    with open(file,'r') as fp:
        cfg.read_file(itertools.chain(['[global]'], fp), source=file)

    # config.read(file,encoding='utf-8')
    gw_sip = cfg.get('test_sip_endpoint','gw_sip')

猜你喜欢

转载自www.cnblogs.com/Ray-Lei/p/10251675.html