map函数会根据提供的函数对指定的序列做映射,放回的结果保存在迭代器中
func=lambda x:2*x-1
res=map(func,[1,2,3,4,5])
print(list(res))

func=lambda x,y,z:x+y+z
res=map(func,[1,2,3],[4,5,6],[7,8,9])
for i in res:
print(i)

res=map(lambda x,y:{x:y},['a','b','c'],[1,2,3])
print(list(res))

博客介绍了Python中map函数的功能,它能根据提供的函数对指定序列做映射,映射结果会保存在迭代器中。
5854

被折叠的 条评论
为什么被折叠?



