首先调用文档中关于map函数的介绍
map(function, iterable, …)
Apply function to every item of iterable and return a list of the results. If additional iterable arguments are passed, function must take that many arguments and is applied to the items from all iterables in parallel. If one iterable is shorter than another it is assumed to be extended withNoneitems. If function is None, the identity function is assumed; if there are multiple arguments, map() returns a list consisting of tuples containing the corresponding items from all iterables (a kind of transpose operation). The iterable arguments may be a sequence or any iterable object; the result is always a list.
来对文档进进行说明
Apply function to every item of iterable and return a list of the results.
对可迭代函数’iterable’(迭代器)中的每一个元素应用‘function’(函数)方法,将结果作为list(列表)返回
eg:
If additional iterable arguments are passed, function must take that many arguments and is applied to the items from all iterables in parallel.
如果给出了额外的可迭代参数,则对每个可迭代参数中的元素‘并行(parallel)’应用‘函数‘(function) ,这里所谓的并行 大概就是同时执行的意思吧。
eg:
这就是并行的运行效果.在每个list中,取出了下标相同的元素,执行了a_b_c()
If function is None, the identity function is assumed
如果’函数 (function)’指定的是‘None’,自动假定一个‘一致(identity)’函数
if there are multiple arguments, map() returns a list consisting of tuples containing the corresponding items from all iterables (a kind of transpose operation)
如果有多个参数,返回一个由元组组成的列表。
eg:
其实也可以这样理解这个map函数
map(f, iterable) ——> [f(x) for x in iterable] (列表推导)
若是将三个list看做矩阵的话:
1 2 3
4 5 6
7 8 9
实际上map()只做了列上面的运算
但是如果用列表推导的话 结果会成为一个提卡尔乘积。
result: