Python--lambda function

The lambda function returns the function name as the result

  • The lambda function is an anonymous function, that is, a function without a name
  • Use lambda reserved word definition, the function name is to return the result
  • The lambda function is used to define a simple function that can be expressed in one line

<Function name> = lambda <parameter>: <expression>

 Use lambda functions with caution

  • Lambda functions are mainly used as parameters of some specific functions or methods
  • Lambda functions have some fixed uses
  • In general, it is recommended to use def to define ordinary functions

Guess you like

Origin www.cnblogs.com/technicist/p/12716877.html