python

关注公众号 jb51net

关闭
首页 > 脚本专栏 > python > python中的与或非运算

简单了解python中的与或非运算

作者:Roc_Atlantis

这篇文章主要介绍了简单了解python中的与或非运算,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

真的很重要,栽了个跟头!!!(虽然以前好像知道。。。)

print(True or False and False)
print((True or False) and False)
# True
# False

这里有一个python运算符的优先级

not > and >or  

not > and >or

not > and >or

有括号的除外

运算返回的值是决定表达式运算结果的值。

比如True or False 、False or True返回True,True and False返回False。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

您可能感兴趣的文章:
阅读全文