匿名函数

a = lambda x:x+1 #冒号前是入参,冒号后是返回值
result = a(1)
print(result)

b = lambda x,y:x+y
print(b(2,3))


# filter(str,[1,2,3,4,5])
res = filter(lambda x:str(x),[1,2,3,4,5])
print(res)

简单函数可以直接写成匿名函数不带函数名这种!

原文地址:https://www.cnblogs.com/Mezhou/p/13616256.html