1 >>> a=3 2 >>> b=4 3 >>> c=5 4 >>> d=6 5 >>> c>d and b>a or d>c 6 True 7 ‘’‘>>> c>d and b>a not c>d 8 File "<stdin>", line 1 9 c>d and b>a not c>d 10 ^ 11 SyntaxError: invalid syntax’‘’ 12 >>> c>d and b>a or not c>d 13 True 14 >>> c>d and b>a or not d>c 15 False 16 >>>
由上所述,逻辑运算符中的优先级为not>and>or
不过一般写代码时最好不要这样写,尽量给代码加上括号,方便读者阅读