Python-Boolean operation

一、布尔运算符

1、x and y: if x is false, then x, else  y

2、x or y: if x is false, then y, else x

3、not x: if x is false, then true, else false

 

二、运算结果

>>> 'a' and 'b'
'b'

>>> '' and 'b'
''

>>> 'a' or 'b'
'a'

>>> '' or 'b'
'b'

>>> not 'a'
False

>>> not ''
True

 

posted on 2017-10-24 17:09  乔~惜  阅读(472)  评论(0编辑  收藏  举报