In [11]: False or True
Out[11]: True
python 中的三目运算符:
In [1]: 1==1 and '123' or '456'
Out[1]: '123'
魔幻的python语句:
In [6]: a = 1 if 1==2 else 2
In [7]: a
Out[7]: 2
In [8]: a = 1 if 1==1 else 2
In [9]: a
Out[9]: 1
In [11]: False or True
Out[11]: True
In [1]: 1==1 and '123' or '456'
Out[1]: '123'
In [6]: a = 1 if 1==2 else 2
In [7]: a
Out[7]: 2
In [8]: a = 1 if 1==1 else 2
In [9]: a
Out[9]: 1