Interpretation and use of lambda functions

Lambda function syntax contains only one statement, such as:
lambda arg1,arg2,.....argn:expression。


There is such a code:

f = lambda a, b, c: a + b + c, lambda represents anonymous function key.
Colon: before a, b, c indicate that they are parameters of this function. Anonymous function does not need to return to the return value, the return value is the result of the expression itself.

 

Generally, there are about several usage:

 

1. The no-argument anonymous function

 

 

2. anonymous function with parameters

 

 

3. returns an ancestral

 

 

4. Return a dictionary

 

Guess you like

Origin www.cnblogs.com/heimaguangzhou/p/11696392.html