Reminder: if the reader has not learned to def
define functions, please read here first
Definition form
<函数名> = lambda <参数列表>: <返回值>
Equivalent to:
def <函数名>(<参数列表>):
return <返回值>
It can also be defined as an anonymous function (function without a name):
lambda <参数列表>: <返回值>
It can be confirmed lambda
that the type of the function object is def
the same as the one defined, both function
:
transfer
If it is an anonymous function, the call form is:
(lambda <参数列表>: <返回值>)(<参数列表>)
If not, the call form is:
<函数名>(<参数列表>)
Calculate a + b a+ba+Function of b :
No return value
lambda
The function can also return no value.
For example
, lambda
functions with no return value are generally used to do things , such as print('Hello World')
etc.