Example Analysis of receiving parameters of Python map
This article mainly introduces the relevant knowledge of "case analysis of Python map receiving parameters". The editor shows you the operation process through the actual case. The operation method is simple, fast and practical. I hope this article "case analysis of Python map receiving parameters" can help you solve the problem.
Description
1. The map function takes two arguments, one is the function, and the other is Iterable.
2. Map acts on each element of the sequence in turn, and returns the result to the new Iterator.
Example
# map uses # to find the square of arr each element arr = [1,2,3,4,5,6,7,8] def square (x): return x * xresult = map (square, arr) print (list (result)) # lambda with map result1 = map (lambda x: X * x, arr) print (list (result1)) # lambda uses multiple parameters with map If the number of arr and arr1 is different, only the minimum number will be counted. If the number of arr1 is less than arr, only 5 elements will be returned. Otherwise, fewer arr will only calculate the number of arr digits arr1 = [1, 2, 3, 4, 5, 6] result2 = map (lambda x, y: X * x + y, arr, arr1) print (list (result2)). Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.