- 单星号解包元组,按位置参数传参
- 双号解包字典,按关键字传参
*args, **kwagrs 用于吸收任意多的参数
>>> name = "jack"
>>> age = "23"
>>> def fun(*args, **kwagrs):
... print(args, kwagrs)
... print(*args,**kwagrs)
...
>>> fun(name, age, d=2, c=3)
('jack', '23') {'d': 2, 'c': 3}
jack 23 d c
用元组与字典传参
>>> def fun(a,b,c=None, d=None):
... print(a,b)
... print(c,d)
...
>>> tuple = (1, 2)
>>> dic = {"c":20, "d":10}
>>> fun(*tuple, **dic)
1 2
20 10