print(6 and 0 or 5==9 and 4 and '7' or 0 and 8)
print(4 or 8 and 56==0 or 5 and 0 or 5 and 'hoe' or 0 and 'f')
Python中多个逻辑运算符的计算顺序是什么? 是从任一侧开始顺序进行的吗?
答案 0 :(得分:0)
它遵循operator precedence中定义的优先顺序。
简而言之,不是> AND> OR。
您的代码翻译为:
(6 and 0) or (5==9 and 4 and '7') or (0 and 8)
(4) or (8 and 56==0) or (5 and 0) or (5 and 'hoe') or (0 and 'f')