# 用小写比较文本
str_value = "True"
bool_value1 = str_value.lower() == "true"
# bool_value1 is True
# 几个词都算作真
str_answer = "yes"
bool_value2 = str_answer.lower() in ("true", "yes", "1")
# bool_value2 is True
# 陷阱:bool() 不是解析器,"false" 是非空字符串
bool_value3 = bool("false")
# bool_value3 is True
# 只有空字符串为假
bool_value4 = bool("")
# bool_value4 is False
print(f"{bool_value1 = }")
print(f"{bool_value2 = }")
print(f"{bool_value3 = }")
print(f"{bool_value4 = }")