python中三元运算: x if y else z 即把条件放在中间。 >>> x=3 if a>=3 else 2 >>> x 2 >>> a 1 >>> a=5 >>> x=3 if a>=3 else 2 >>> x 3 >>>