布尔表达式到底是什么?
不就是True和False,难道还有其他的?
通过条件组合得到结果,True为真,False为假。
逻辑运算符and ,or ,not。运算的优先级not >and >or
比如
print(1>2 and 1<2 or 5>4 and 9>8) #False
print(1>2 and (1<2 or 5>4) and 9>8) #True
写得很详细的一篇文章,关于描述python的表达式:
https://www.cnblogs.com/ruo-li-suo-yi/p/7352490.html
1.布尔类型
布尔类型、布尔表达式、布尔操作符
布尔类型的结果:true和false
布尔表达式:数值比较、字符串比较、in和not in,比较的结果是bool
2.布尔类型的结果
布尔类型的结果只有2个值:false和true
3.关系运算符
关系运算符:= 、!=、>、<
其中== 表示值/内容相等,对象相等的需要根据id去判断,用is去表达。(其中值-5~256之间的数,a==b 地址是一致的)