python map()

map():根据提供的函数对指定序列做映射。

调用:

map(func,iterable)

第一个参数 func表示函数,第二个参数是可迭代类型的数据,返回iterable里的元素调用func后的结果组成的迭代器。

a=map(lambda x: x ** 2, [1, 2, 3, 4, 5])
print(a)
for i in a:
    print(i)

 输出:

<map object at 0x0000026AC5905D30>
1
4
9
16
25
原文地址:https://www.cnblogs.com/zhhy236400/p/9948642.html