1. anonymous function
The general cock-silk function is defined like this
def DS (x): return 2*x+1
And the anonymous function is like this.
Lambda x:2*x+1
Benefits of using Anonymous functions
1, can make the function more concise
2, no need to consider naming, do not have the name of the child racked up ha ha ha haha
3, simplify the code, improve the readability of the Code
2, two commonly used built-in functions 1) filter (parameter 1, parameter 2) parameter 2 with in Parameter 1 is calculated if the true final return output is true for the collection
Use lambda expressions and filter () to find a multiple of 3 within 100
List (filter (lambdanot (n%3), range (1, 100)))
Use the list deduction to replace the problem
for inch if not (i%3)]
2, Map (parameter 1, parameter 2) parameter two generation into parameter 1 calculates the collection of the returned calculated value
Analog zip () packages two sequences into elements as list form
>>> list (map (lambda x, y: [x, Y], [1, 3, 5, 7, 9], [2, 4, 6, 8,])) [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]
Lambda expression for Python3