语法
map( function, iterzble, ...)
返回值
python 3 返回迭代器
实例
def num(x):
return x**2
index=map(num,[1,2,3])
print(index)
输出
<map object at 0x00000187708B0160>
#使用list()转换为列表
print(list(index))
输出
[1, 4, 9]
语法
map( function, iterzble, ...)
返回值
python 3 返回迭代器
实例
def num(x):
return x**2
index=map(num,[1,2,3])
print(index)
输出
<map object at 0x00000187708B0160>
#使用list()转换为列表
print(list(index))
输出
[1, 4, 9]