Python最牛逼内建函数之 map()

map

map(func, iter1,iter2...) 映射出一个新的迭代器,其中func 为映射规则,一般使用lambda 函数进行定义,后面的iter 为被映射的迭代器,使用后生成一个map类的迭代器,读取它使用list(map(lambda x:....,iter1))

>>> a = map(lambda x: x ** 2,[1,2,3,4,5])
>>> a
<map object at 0x101a86da0>
>>> list(a)
[1, 4, 9, 16, 25]
原文地址:https://www.cnblogs.com/rendawei/p/7057009.html