https://www.cnblogs.com/linhaifeng/articles/6113086.html
——————————————————————————————————————
九、匿名函数
def calc(x): return x+1 res=calc(10) print(res) #输出1 print(calc) #输出2 print(lambda x:x+1) #输出3 func=lambda x:x+1 print(func(10)) #输出4
运行结果:
11
<function calc at 0x0000000002311D08>
<function <lambda> at 0x0000000002311C80>
11
name = 'alex' def change_name(x): return x + '_sb' res = change_name(name) print(res)
运行结果:
alex_sb
name = 'alex' func=lambda x:x+'_sb' res=func(name) print('匿名函数的运行结果',res)
运行结果:
匿名函数的运行结果 alex_sb
func=lambda x,y,z:x+y+z print(func(1,2,3))
运行结果:
6