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
不過一般寫代碼時最好不要這樣寫,盡量給代碼加上括號,方便讀者閱讀