In python, these two parameters is variable in python, * arg represent any number of unknown parameters, type tuple; ** kwargs represents keyword parameter of dict.
The following example code * args calculated using the incoming number n of the sum of squares, n being variable
1 def calc(*numbers): 2 sum = 0 3 for n in numbers: 4 sum = sum + n * n 5 print(sum) 6 7 calc(1,2,3,4)
The result is output 30 runs.
The following code is the Usage Parameter ** kwargs
1 def func(**kwargs): 2 print(kwargs) 3 func(a=1, b=2)
Run results