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。

技术分享图片

 

文章来自:https://www.cnblogs.com/Roc-Atlantis/p/9094040.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3