python-filter,reduce

filter

1. Function: filter out some elements

2. Usage: list(filter(lambda x:x>0),range[-5,5])

list: used to display the results

lambda x:x >0 filter condition

range[-5.5], the set of elements to filter

deduce

1. Function: apply the function to each team element and run to the final result

2.用法:reduce((lambda x,y:x+y),[1,2,3,4]) = 10

At each step, reduce passes the current sum and the next element, defaulting to the first element as the starting value

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324815072&siteId=291194637