发布时间:2019-09-13 09:29:19编辑:auto阅读(3220)
二元表达式:
wide=1 new_w = 299 if not wide else 28 print(new_w) new_w = 299 if wide>0 else 28 print(new_w)
a,b=1,2 max = a if a > b else b
三元表达式
wide=0 new_w = 299 if wide>0 else 'sdf' if wide==0 else 28 print(new_w)
三目运算符:
这个是三目运算符(伪,因为Python根本就没有三目):
val = float(raw_input('Age: '))
print 'You should be', ('working','retired')[val>65]
上一篇: ActiveMQ平台搭建 python
下一篇: python全局变量的使用
51413
50888
41476
38254
32759
29670
28466
23387
23320
21650
1743°
2478°
2073°
2006°
2361°
2032°
2741°
4584°
4407°
3138°