Collection functions
Collect actual parameters into tuples and dictionaries
1 defPrint_params (*params):2 Print(params)3 """4 Print_parasm (a)5 Output: (+/-)6 """7 8 defPrint_params_2 (* *params):9 Print(params)Ten One """ A print_params_2 (X=1, y=2, z=3) - output:{' z ': 3, ' X ': 1, ' Y ': 2} - """
The *, * * operation can also be used to perform the opposite action
def Add (x, y ): return x += (1, 2) Add (# output:3
Calling a method when the name of the global variable and the local variable within the function are to be accessed by the function
1 # This kind of operation is best not to use 2def Combine (parameter):3 Print (Parameter + globals () ['parameter'])
def multiplier (factor): def multiplybyfactor (number): return number * factor return multiplybyfactor# The function of the function that stores its scope, like Multiplybyfactor, is called a closure .
Basic Python tutorial Sixth study notes