python basis of three: function

def name (parameter 1, parameter 2, parameter 3, ...)

You can customize some of the functions they need to simplify their work.

Such as: a calculation function Custom

  def  mycount(a,b,c):

    y=a+b-c

    return y

Call: mycount (5,3,1) is output: 5 + 3-1 = 7

lambda: anonymous functions for simple function definition

Usage: lambda x: x + x colon: result is returned back to the operation of the object x

Lambda anonymous functions often apply () appear together, to achieve vertical or horizontal rows of operations

  apply (lambda x: x + 1, axis = 0 or axis = 1) axis = 0 is the default application function a longitudinal, axis = 1 represents the lateral application function

Guess you like

Origin www.cnblogs.com/dataxiong/p/11542384.html