def __strict_strtobool(value):
from distutils.util import strtobool
if isinstance(value, bool):
return value
try:
lower_text = value.lower()
except AttributeError:
raise ValueError("invalid value '{}'".format(str(value)))
binary_value = strtobool(lower_text)
if lower_text not in ["true", "false"]:
raise ValueError("invalid value '{}'".format(str(value)))
return bool(binary_value)
评论列表
文章目录