Home > Article > Backend Development > Introduction to the basic use of lambda expressions in python
This article explains in detail the basic usage of lambda expressions in python
lambdaExpression, also called anonymous function, is an ordinary function' The format of the mini version of '
lambda expression:
lambda formal parameter: expression
func1 = lambda x:x+1
func1(10 )
>>>11
As can be seen from the above example, the lambda function does not need to manually define the return value. The result of the expression will be returned directly as the return value.
For example, define a lambda function and add a bitch string in front of each string.
func2 = lambda name:"bitch "+ name
print func2("jolin")
>>>bitch jolin
The above is the detailed content of Introduction to the basic use of lambda expressions in python. For more information, please follow other related articles on the PHP Chinese website!