Python - map built-in functions learning

Look at the manual definition:

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.

map () function is commonly used in higher-order function, is a function of the first parameter, the second parameter is the iteration object, the object function is to be an iterative function were used, returns the map object.
python map function is one of the built-in functions, built-in functions overview see: https://mp.csdn.net/mdeditor/90751587#
https://blog.csdn.net/oaa608868/article/details/53506188

Example:

a= [1, 2, 3]
def f(x):
    return x**2
print(map(f,a))#output:map object at  0x0000024C36EC1C50
print(list(map(f,a)))#使用list实现强制转化,output:[1,4,9]

At this time, the function f without parameters;
containing a plurality iterables, after the end of the shortest, the iteration stops

Guess you like

Origin blog.csdn.net/houhuipeng/article/details/90757515