尝试使用此代码从.ini文件中获取一些数据,当我尝试打开.ini时,它给出我在做什么错?
config = configparser.ConfigParser()
config.sections()
config.read('FILE.ini') #throws file contains no section headers
print(config['DEFAULT']['toAddr'])
x = config.get('DEFAULT', 'to')
。ini文件
['DEFAULT']
to = "blah"
我在Win 10上使用Python 3.7 64
ini文件的标头中不应包含引号。
使用
[DEFAULT]
to = "blah"
代替
['DEFAULT']
to = "blah"