The specific meaning of the Python apply function:
The Apply (func [, args [, Kwargs]]) function is used to indirectly invoke a function when a function parameter already exists in a tuple or dictionary. Args is a tuple that contains the arguments passed by position that will be supplied to the function. If args is omitted, no arguments are passed, and Kwargs is a dictionary containing the keyword arguments.
The return value of apply () is the return value of the Func (), and the element parameters of apply () are ordered, and the order of the elements must match the order of the Func () Form parameters
Here are a few examples to say in detail:
1, assuming that the implementation of the method without parameters
Def say ():
print ' Say in '
Apply (say)
The result of the output is ' say in '
2, the function only with the tuple parameters.
Def say (A, B):
Print A, b
Apply (say, ("Hello", "Lao Wang Python"))
The result of the output is Hello, Lao Wang Python
3, function with keyword parameters.
def say (a=1,b=2):
Print A, b
def haha (**kw):
#say (kw)
Apply (say, (), kw)
print haha (a= ' a ', b= ' B ')
The result of the output is: A, b
Python apply () function