The keyword parameter and positional parameters are defined when the function is called
Keyword parameters are key-value pairs appear, unordered, one more no, less one not
Positional parameters, orderly, one more no, one less.
Mashup: All positional parameters must be on the left side of the keyword parameter
The default parameter is defined in the function definition and can be used without arguments when the function is called.
Variable length parameter: *args, **kwargs
Mixing of variable length parameters and positional parameters
1 defAdd (x, y):2 returnX +y3 defAdd_1 (x=0, Y=1):4 returnX +y5 6 defList_add (x, *args, * *Kwargs):7 Printx8 Printargs9 PrintKwargsTen One Print "function position parameter%d"% Add (1,3) A Print "function keyword parameter:%d"% Add (x=2, y=4) - Print "function default parameter%d"%add_1 () - Print "function position keyword mash%d"% Add (0, y=2) theList_add (1, 2, 3, 4, name=1) -List_add (1,*[2,3,4],**{"name": 1})
View Code
1 function Position parameter 42function keyword parameter: 63function default Parameter 14function position keyword mash up 2516(2, 3, 4)7{'name': 1}819(2, 3, 4)Ten{'name': 1} One AProcess finished with exit code 0
View Code
[Python] [Oldboy] keyword parameters and positional parameters, default parameters, variable length parameters (nameless, famous)