1、有两种值 True和 Flase

2、布尔类型值得运算

与运算:只有两个布尔值都为 True 时,计算结果才为 True。

True and True   # ==> True  
True and False   # ==> False
False and True   # ==> False
False and False   # ==> False

或运算:只要有一个布尔值为 True,计算结果就是 True。


True or True # ==> True  
True or False # ==> True 
 
False or True # ==> True 
 
False or False # ==> False


非运算:把True变为False,或者把False变为True:


not True   # ==> False
not False  # ==> True
3、布尔类型还可以与其他数据类型做 and、or和not运算
例子:a = True
print a and 'a=T' or 'a=F'结果:a=T
字符串 'a=T',这是为什么呢?
0
空字符串''
None



python not true python not true and false_python




例子:



python not true python not true and false_语言_02



输出:


hello,python
 
 
hello,world