格式: true_res if condition else false_res
true_res if condition else false_res
Meto 1:
Meto 2:
>>> x = 2
>>> x+1 if x!=1 else --x
3
python 三目运算符
原文:https://www.cnblogs.com/We612/p/10207161.html