用法:
ConfigParser.BOOLEAN_STATES默认情况下,使用
getboolean()时,配置解析器会考虑以下值True:'1','yes','true','on'和以下值False:'0','no','false','off'。您可以通过指定字符串的自定义字典及其布尔结果来覆盖它。例如:>>> custom = configparser.ConfigParser() >>> custom['section1'] = {'funky': 'nope'} >>> custom['section1'].getboolean('funky') Traceback (most recent call last): ... ValueError: Not a boolean: nope >>> custom.BOOLEAN_STATES = {'sure': True, 'nope': False} >>> custom['section1'].getboolean('funky') False其他典型的布尔对包括
accept/reject或enabled/disabled。
相关用法
- Python configparser.ConfigParser.readfp用法及代码示例
- Python configparser.ConfigParser.SECTCRE用法及代码示例
- Python configparser.ConfigParser.read用法及代码示例
- Python configparser.BasicInterpolation用法及代码示例
- Python configparser.ExtendedInterpolation用法及代码示例
- Python contextlib.AsyncContextDecorator用法及代码示例
- Python contextlib.AsyncExitStack用法及代码示例
- Python contextlib.ExitStack.pop_all用法及代码示例
- Python contextlib.redirect_stdout用法及代码示例
- Python contextlib.aclosing用法及代码示例
- Python contextlib.ExitStack用法及代码示例
- Python contextlib.contextmanager用法及代码示例
- Python contextvars.ContextVar.reset用法及代码示例
- Python contextlib.closing用法及代码示例
- Python contextlib.nullcontext用法及代码示例
- Python contextlib.ContextDecorator用法及代码示例
- Python contextvars.Context.run用法及代码示例
- Python contextlib.suppress用法及代码示例
- Python collections.somenamedtuple._replace用法及代码示例
- Python collections.somenamedtuple._asdict用法及代码示例
注:本文由纯净天空筛选整理自python.org大神的英文原创作品 configparser.ConfigParser.BOOLEAN_STATES。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
