python 是否短路 bool 值,如 a==b==c,即,如果 a==b 为假,则不评估第二个相等性?复合相等性只是 a==b 和 b==c 的语法糖吗?
请您参考如下方法:
是的。来自docs :
Comparisons can be chained arbitrarily, e.g.,
x < y <= zis equivalent tox < yandy <= z, except thatyis evaluated only once (but in both caseszis not evaluated at all whenx < yis found to be false).
这适用于任何链式比较,与选择的比较运算符无关。
