Python中if-else语句的多种写法
a, b, c = 1, 2, 3
#1.常规
if a>b:
c = a
else:
c = b
#2.表达式
c = a if a>b else b
#3.二维列表
c = [b,a][a>b]
#4.传说是源自某个黑客
c = (a>b and [a] or [b])[0]
a, b, c = 1, 2, 3
#1.常规
if a>b:
c = a
else:
c = b
#2.表达式
c = a if a>b else b
#3.二维列表
c = [b,a][a>b]
#4.传说是源自某个黑客
c = (a>b and [a] or [b])[0]