【发布时间】:2011-05-27 13:04:03
【问题描述】:
我正在观看2007 video on Advanced Python or Understanding Python,在 18'27" 时,演讲者声称“在 Python 中,and 和 or 返回两个值之一,而 not 总是返回一个布尔值。 " 什么时候是这样的?
据我所知,and 和 or 也返回布尔值。
【问题讨论】:
-
可能会让您感到困惑的是,您可以在似乎需要布尔值的上下文中使用任何数据类型。 'if 17: blah' 是合法的。
标签: python operators logical-operators