map函数类似一个生成器
具体用例如下:
def add(x): return x**2 a =[1,2,3] b = map(add,[1,2,3]) print( list(map(add,[1,2,3])) ) print(b,type(b)) for i in b: print(i)
对应结果为
[1, 4, 9] <map object at 0x000000000396D320> <class 'map'> 1 4 9