python 使用中遇到的問題,記錄及解決方法

一、讀取configparser 配置文件報錯   :spa

提示:ip

 ConfigParser.MissingSectionHeaderError when parsing rsyncd config file with global optionsutf-8

解決方法:get

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

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')io

相關文章
相關標籤/搜索