python 使用中遇到的問題,記錄及解決方法
阿新 • • 發佈:2019-01-10
1、讀取configparser 配置檔案報錯 :
提示:
ConfigParser.MissingSectionHeaderError when parsing rsyncd config file with global options
解決方法:
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')