标签:语句 else nbsp bsp span 方式 turn 三元 if语句
简化if语句的形式
定义方式:
判断为真的值 if 条件 else 其它情况
例:
# 以前的if def foo(x): if x > 3: return ‘ok‘ else: return ‘no‘ # 三元表达式求谁更大 def max2(x,y): return x if x > y else y print(max2(1,3))
标签:语句 else nbsp bsp span 方式 turn 三元 if语句
原文地址:http://www.cnblogs.com/liuxiaowei/p/7226573.html