1. 程式人生 > >python 使用中遇到的問題,記錄及解決方法

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

ref source ror 遇到的問題 per with open 解決方法 sip oba

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‘)

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