python ------ lambda (anonymous function)

With ordinary functions and anonymous functions can easily find compare the role of the anonymous function

#普通函数
def add(a,b):
    return a + b

print(add(2,3))

#匿名函数
add = lambda a,b : a + b
print(add(2,3))

Anonymous function naming convention, with identification lambda as keys, a colon (:) indicates the left parameter (a, b) function received a colon (:) right side represents the return value (a + b Function)

Because lambda not need to name when creating, when we passed to the function, directly into the anonymous function is more convenient

Guess you like

Origin www.cnblogs.com/hyxk/p/11372569.html