【发布时间】:2020-01-01 16:26:17
【问题描述】:
尝试使用此代码从 .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
【问题讨论】:
-
预期行为是什么,当前的问题是什么?
when I try to open the .ini it gives What Am I doing wrong?- 你漏掉了一部分句子吗?