python内置函数 map

map() 会根据提供的函数对指定序列做映射。

第一个参数 function 以参数序列中的每一个元素调用 function 函数,返回包含每次 function 函数返回值的新列表。

map(function, iterable, ...)

Return an iterator that applies function to every item of iterable, yielding 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. With multiple iterables, the iterator stops when the shortest iterable is exhausted. For cases where the function inputs are already arranged into argument tuples, see itertools.starmap().

例子 : 列表形式的digits 转化为数字

digits_list = [1,2,3]
digits_str =str(int(''.join(map(str,digits_list))))

猜你喜欢

转载自www.cnblogs.com/francischeng/p/9441148.html