python中的三元运算符

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_30500113/article/details/84034067

python中的三元运算符

三元运算符通常在Python里被称为条件表达式,这些表达式基于真(true)/假(false)的条件判断,在Python 2.4以上才有了三元操作。
下面是一个伪代码和例子:
伪代码:

#如果条件为真,返回真 否则返回假
condition_is_true if condition else condition_is_false

在这里插入图片描述

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_30500113/article/details/84034067