([False, True] and [True, True]) 计算结果为 [True, True]

rvb*_*eto -1 python boolean python-3.x

我在 python 3 中观察到以下行为:

>>> ([False, True] and [True, True])
[True, True]

>>> ([False, True] or [True, True])
[False, True]
Run Code Online (Sandbox Code Playgroud)

我期待的恰恰相反:

[False, True] and [True, True] = [False and True, True and True] = [False, True]
[False, True] or [True, True] = [False or True, True or True] = [True, True]
Run Code Online (Sandbox Code Playgroud)

观察到的行为如何有意义,我如何才能实现所需的行为?

Mar*_*som 5

每个列表都作为一个整体进行评估。 [False, True]为真,也是[True, True]因为只有空列表为假。

and返回最后一个 True 元素,但or返回第一个。