码迷,mamicode.com
首页 > 编程语言 > 详细

Python中的三元运算

时间:2017-12-31 18:20:34      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:class   center   gpo   运算   nbsp   三元运算   else   pos   条件   

Python中的三元运算

三元运算又称三目运算。

B=1

If B==1:

    a=123

else :

    a=456

上面程序等价于:

B=1

a=123 if B==1 else 456

如果条件满足则a=123,否则a=456

Python中的三元运算

标签:class   center   gpo   运算   nbsp   三元运算   else   pos   条件   

原文地址:https://www.cnblogs.com/xshan/p/8157985.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!