本文虽为汇总贴但也会添加个人理解稍作加工,仅作为熟悉python和未来查询使用
python中函数及其意义汇总
参考资料 菜鸟教程
函数
map()
语法
map(function, iterable, …)
意义 依次调用可迭代对象iterable中的元素进行function运算实例
>>>def square
(x
) :
... return x
** 2
...
>>> map(square
, [1,2,3,4,5])
[1, 4, 9, 16, 25]
>>> map(lambda x
: x
** 2, [1, 2, 3, 4, 5])
[1, 4, 9, 16, 25]
>>> map(lambda x
, y
: x
+ y
, [1, 3, 5, 7, 9], [2, 4, 6, 8, 10])
[3, 7, 11, 15, 19]