map
lst = [1,2,3,4,5,6] print(list(map(lambda x:x*x,lst))) >>>[1, 4, 9, 16, 25, 36] Pass in a function in the map, calculate the following loopable object, and output the result
filter
lst = [1,2,3,4,5,6] print(list(filter(lambda x:x>2,lst))) >>>[3, 4, 5, 6] Enter a function, filter the following loopable objects, and output the results
reduce
import functools lst = [1,2,3,4,5,6] print(functools.reduce(lambda x,y:x+y,lst,999)) >>> 1020 In fact, it is 999 +21
to achieve the cumulative effect