手机
当前位置:查字典教程网 >脚本专栏 >python >Python三元运算实现方法
Python三元运算实现方法
摘要:本文实例讲述了Python三元运算实现方法。分享给大家供大家参考。具体分析如下:Python中没有像C++和Java等语言中的三元运算符,但...

本文实例讲述了Python三元运算实现方法。分享给大家供大家参考。具体分析如下:

Python中没有像C++和Java等语言中的三元运算符,但是可以用if else语句实现相同的功能:

复制代码 代码如下:>>> condition = True

>>> print 'True' if condition else 'False'

True

>>> condition = False

>>> print 'True' if condition else 'False'

False

>>>

希望本文所述对大家的Python程序设计有所帮助。

【Python三元运算实现方法】相关文章:

python中定义结构体的方法

Python学习资料

python二分法实现实例

python33 urllib2使用方法细节讲解

python二叉树遍历的实现方法

Python strip lstrip rstrip使用方法

Python实现的几个常用排序算法实例

python去掉字符串中重复字符的方法

python冒泡排序算法的实现代码

python基础教程之类class定义使用方法

精品推荐
分类导航