Python学习之not,and,or篇

时间:2023-03-09 09:19:19
Python学习之not,and,or篇

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