Python三元运算符
三元运算符
三元运算符通常在Python⾥被称为条件表达式,这些表达式基于真(true)/假(not)的条件判 断,在Python 2.4以上才有了三元操作
#如果条件为真,返回真否则返回假
condition_is_true if condition else condition_is_false
三元运算符通常在Python⾥被称为条件表达式,这些表达式基于真(true)/假(not)的条件判 断,在Python 2.4以上才有了三元操作
#如果条件为真,返回真否则返回假
condition_is_true if condition else condition_is_false