Python布尔值

在学到Python数据类型时,发现与大多数语言没什么区别

布尔值可以用

and

or

not

来运算

and运算是与运算,所有条件都符合才为true

>>> True and True
True
>>> True and False
False
>>> False and False
False
>>> 5 > 3 and 3 > 1
True
or运算是或运算,只要其中有一个为True
>>> True or True
True
>>> True or False
True
>>> False or False
False
>>> 5 > 3 or 1 > 3
True
not是与非运算,它是一个单目运算符,把true变成false,把false变成true
>>>not True
false
>>>not Flase
true
>>>not 1>2
true


空值
空值为None
None不能理解为0;0是有意义的,None是一个特殊的空值
变量
变量必须是大小写字母,数字和_的组合
待续。。
 
posted @ 2017-05-19 16:22  it大虫  阅读(998)  评论(0)    收藏  举报