python boolean opeator优先级

来源:互联网 发布:网络推广员工资 编辑:程序博客网 时间:2024/05/27 20:52

1.有三个布尔操作:

not, and, or

2.  优先级

  1. not is evaluated first;
  2. and is evaluated next;
  3. or is evaluated last.
3. 通过加( )可以改变计算顺序

例子:

1. 在console输入:

not not True or False and not True

输出是:True

2. 在console输入:

(not not True or False) and not True

输出是:False





原创粉丝点击