1、and、or、not的優先順序 優先順序從大到小:() not and or 2、輸出返回值時,x or y,x為True,則返回x print(1 or 2) 返回1 print(3 or 2) 返回3 3、輸出反回值時,x and y,x為True,則返回Y( and與or 相反 ) print ...
1、and、or、not的優先順序
優先順序從大到小:()>not>and>or
2、輸出返回值時,x or y,x為True,則返回x
print(1 or 2) 返回1
print(3 or 2) 返回3
3、輸出反回值時,x and y,x為True,則返回Y(and與or 相反)
print(1 and 2) 返回2
print(3 and 2) 返回2