1
Documentation有一個範例,唯一的部分稱爲設置 這似乎是默認命名空間中的python-脫鉤因此,如果您有:解析的.ini與部分中的python-脫鉤
[settings]
DEBUG=True
可以解析與配置:
from decouple import config
DEBUG = config('DEBUG', default=False, cast=bool) # no section argument
但是,如果我們有定製的部分,如:
[sectionA]
DEBUG=True
[sectionB]
foo="bar"
?
我知道,人們可以很容易地使用ConfigParser解析定製的部分,像這樣:
config_parser.get('sectionA', 'DEBUG') # the corresponding call in ConfigParser
但我不知道它是如何通過做的python-脫鉤因爲它也支持的.ini文件