Python學習之not,and,or篇
運算符示意
- not –表示取反運算。
- and –表示取與運算。
- or –表示取或運算。
運算符優先級
not
> and
> or
。
舉例如下:
bool_one = False or not True and True print bool_one bool_two = False and not True or True print bool_two bool_three = True and not (False or False) print bool_three bool_four = not not True or False and not True print bool_four bool_five = False or not (True and True) print bool_five
程序輸出:
False True True True False