时间:2021-07-01 10:21:17 帮助过:56人阅读
name = "GOGOGO" if True else "HAHA"
等同于:
if True: name = "GOGOGO" else: name = "HAHA" print (name)
执行结果:
GOGOGO
lambda:
f2 = lambda a1,a2: a1+a2 t = f2(1,2) print (t)
等同于:
Python代码
def f2(a1,a2):
return a1+a2
t = f2(1,2)
lambda无法使用if,else等条件判断