【发布时间】:2016-09-07 13:43:55
【问题描述】:
使用 python 的configparser 包读取配置文件时,所有键名都是小写字符串。有人知道如何阅读保留大写和大写单词的字符串吗?
例如:
$cat config.cfg
[DEFAULT]
Key_1 = SomeWord
KEY_2 = Another Word
$ python3
>>> from configparser import ConfigParser
>>> cf = ConfigParser()
>>> cf.read('./config.cfg')
['./config.cfg']
>>> print(cf.defaults())
OrderedDict([('key_1', 'SomeWord'), ('key_2', 'Another Word')])
感谢您的帮助!
【问题讨论】:
-
如果你能解释的更详细,会有更多的答案。
-
抱歉重复了..我没有想到“case”这个词..^.^
标签: python python-3.x configparser