map和reduce

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37195257/article/details/80501692
#map(f,list)
def normalize(x,):

    return x*10


list=[1,2,3,4,5]

print map(normalize,list)
 
 

#reduce(f,list)

def normalize(x,y):

    return x*10+y


list=[1,2,3,4,5]

print reduce(normalize,list)

猜你喜欢

转载自blog.csdn.net/qq_37195257/article/details/80501692