python中 三元表达式

一、用法:

a = lambda x:1 if x > 5 else 2        ---------- if 与 else 后面不加 :
print(a(5))    ------ 结果:2

猜你喜欢

转载自blog.csdn.net/qq_16555103/article/details/86572804