您还可以将字符串转换为布尔值,只要字符串包含True或False (不包含其他任何内容)。例如: status = bool(input('OK to proceed: '))print(type(status)) 当我们运行此输出时: OK to proceed: False<class 'bool'> 即使我们输入0或False,它仍然返回True。
# Given three ints, a b c, print True if b is greater than a, # "bOk" is True, b does not need to be greater than a.a = int(input())c = int(input())
bOk = boo
我正在制作一个不和谐的机器人,它使用SQLite将数据保存在数据库中(仅用于上下文,与问题无关),并且在将用户升级的函数中,如果用户有足够的XP至少升级一次,它将返回True。bool在函数中按预期工作(在我返回bool之前,它是True),但是我一返回它,它就被设置为False。checkLevel(member):
"Checks for devotion level ups, grants them to the member, and then