在CodeAcademy的Python基础教程看到以下布尔型操作符说明,感觉有点像口诀表,还挺有意思。
Boolean Operators
------------------------
True and True is True
True and False is False
False and True is False
False and False is False
True or True is True
True or False is True
False or True is True
False or False is False
Not True is False
Not False is True
"""
试着翻译一下,虽然超简单。
逻辑运算口诀表
------------------------
True and True is True (真与真得真)
True and False is False (真与假得假)
False and True is False (假与真得假)
False and False is False (假与假得假)
True or True is True (真或真得真)
True or False is True (真或假得真)
False or True is True (假或真得真)
False or False is False (假或假得假)
Not True is False (非真即假)
Not False is True (非假即真)
"""
对人而言很简单的逻辑运算,总结为口诀后,看上去像教科书那样让人望而生畏,但对计算机而言,规则越明确越容易执行。