能一步一步教教吗,c语言里面是3<4<5>2是false能理解,现在正常的不懂了。。。。。
There are eight comparison operations in Python. They all have the same priority (which is higher than that of the Boolean operations). Comparisons can be chained arbitrarily; for example, x < y <= z
is equivalent to x < y and y <= z
, except that y is evaluated only once (but in both cases z is not evaluated at all when x < y
is found to be false).
上面的是python3.8.7文档原内容意思是:Python中有八个比较操作。它们都具有相同的优先级(高于布尔运算的优先级)。可以任意链接比较;例如,x<y<=z等同于x<y and y<=z,只是y只计算一次(但在这两种情况下,当x<y为假时,z根本不计算)。
因此 3<4 、4<5、5>2均为True它们and(与)也为True。
请问你是有实际需要才研究这个的么? 还是想了解 Python 语法的详细规则?