Python中的三元运算 Python中的三元运算 三元运算又称三目运算。 B=1 If B==1: a=123 else : a=456 上面程序等价于: B=1 a=123 if B==1 else 456 如果条件满足则a=123,否则a=456