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
原文地址:https://www.cnblogs.com/jessicaxu/p/7724601.html