开始以为Python中没有像其他语言一样的条件判断的缩写形式:
其实,在Python中,是这样写的:
输出结果:
return
(
1
==
1
)
?
"
is easy
"
:
"
my god
"
//
C#中的用法
其实,在Python中,是这样写的:
print
(
1
==
2
)
and
'
Fool
'
or
'
Not bad
'
输出结果:
Not bad
Python 天天美味系列(总)
Python 天天美味(11) - 可爱的大小写
Python 天天美味(12) - 条件判断的缩写
Python 天天美味(13) - struct.unpack
...
本文转自CoderZh博客园博客,原文链接:http://www.cnblogs.com/coderzh/archive/2008/05/04/1181416.html,如需转载请自行联系原作者