When passing real parameters and defining parameters (the so-called real parameters are the parameters passed in when the function is called, and the shape parameters are defined parameters), you can also use two special syntaxes: ''*''**.
Used to call a function***
Test (* ARGs)
* In fact, each element in the ARGs is passed as a location parameter. For exampleCodeIf ARGs is equal to (1, 2, 3), the code is equivalent to test (1, 2, 3 ).
Test (** kwargs)
** The function is to convert the dictionary kwargs into a keyword parameter for transmission. For example, in the above Code, if kwargs is equal to {'A': 1, 'B': 2, 'C': 3}, then this code is equivalent to test (a = 1, B = 2, c = 3 ).
Used to define function parameters***
Def test (* ARGs ):
When defining function parameters, the meaning of * must be different. Here, * ARGs indicates that all the input location parameters are included in the tuple args. For example, if the preceding function calls test (1, 2, 3), the value of argS IS (1, 2, 3 ).
Def test (** kwargs ):
... Similarly, ** is for keyword parameters and dictionaries. If you call test (a = 1, B = 2, c = 3), The kwargs value is {'A': 1, 'B': 2, 'C ': 3.
Common parameter definitions and transmission methods can coexist with *, but it is clear that * must be placed at the end of all location parameters, and ** must be placed at the end of all keyword parameters, otherwise, there will be ambiguity.
Source: http://www.th7.cn/Program/Python/2011-07-07/28728.shtml