lambda相关

g=lambda x:x+1   相当于  def g(x): return x+1

配合filter,map,reduce函数

-----------------------------------------------------

foo=[2,18,9,22,17,24,8,12,27]

 

map(lambda x:x*2+10,foo)     返回列表

可以写成

[x*2+10 for x in foo]             返回列表

可以写成

for x in foo:           

    return x*2+10             返回循环中的单个值

------------------------------------------------------

posted @ 2017-12-01 11:00  eudaemonia  阅读(177)  评论(0编辑  收藏  举报