-
Logical Operators
and or not
In the absence of () priority not> and> or
Both sides are comparison operation when the same priority from left to right
print(2>1and 3<4 or 4>5 and 2<1) x or y #x,y为数字时候:x:非0则为x,x:为0则为y # 非零即True 0 为 Falese and 跟 or 相反 or: 前面非0就打印前面的。 and:前面为0就是0,前面非0就是后面的。 #例子 print(1 and 2 or -1 and 3) #print(2 or 3) #打印结果2
python logical operation of and, or
Guess you like
Origin www.cnblogs.com/he-qing-qing/p/11297913.html
Recommended
Ranking