2018年7月4日

python中的lambda匿名函数和reduce、filter、map函数

摘要: 1 func=lambda x:x+1 2 print(func(1)) 3 #2 4 print(func(2)) 5 #3 6 7 #以上lambda等同于以下函数 8 def func(x): 9 return(x+1) 可以这样认为,lambda作为一个表达式,定义了一个匿名函数,上例的代码x为入口参数,x+1为函数体。 在这里lambda简化了函数定义的书写形式,使代码更为... 阅读全文

posted @ 2018-07-04 18:21 糖糖大大 阅读(279) 评论(0) 推荐(0) 编辑

导航