1. Functions and parameters (actual parameters)
The creation of a function in Python is Def, the function name is Def f (), the F function name, Def f (A, b), here A-B is two parameters, the function name is custom, and the parameters are custom, so be free. Look at the following effect:
Here f is the argument, and then the function above is called.
The following explains the difference between *args and **kw. 2.*args
The value behind the * is custom, as long as it is not a number, it can be defined as *ABC,*CCC, and Len () is the function, which means to return the length of the string. Then the front of the B is the normal parameter, print a print B is echo 1, 2, because I call F (1,2,3,4,5), remove two ordinary parameters, the remaining three values are 4,5,6, as the name implies the length of 3.
3.**kw
* * and * custom are the same, * * is also custom, followed by a number on the line. What I'm defining here is **d, here is not the same, here you will find a loop here, and then in print, you may not understand, you look at the bottom of the F () function call, call the final answer to a key-value pair form, and then look at the above print x+ ': ' +str (C[x]) will be relaxed, you will say what STR is, str () is a function, his meaning is that the number of variables or constants can be changed to a character variable or constant. So when we call him, name= ' Zhangsan ' is quoted here because this is a string, and age=13 is not quoted, because 13 is an integer type.
4.* and * * Combined usage
Because I have spoken in front of the use of * and * *, merged together, they are unchanged, the position has not changed. When you see this here you will say * and * * What is the difference, yes, their difference is that * contains other numbers, in this case *c is a tuple, and **d here contains a string or according to print x+ ': ' +str (D[x]), the type is XX=XX, Contained in D, so that we can clearly distinguish and learn it!
The difference between function parameters *args and **kw in Python