函数定义阶段,*args, **kwarg的作用是归集。标签:cherry,args,kwargs,print,type,def From: https://www.cnblogs.com/leeyong49/p/16664817.html
函数执行阶段, *args, **kwargs是作用是解压。
def doff(arg1, *args):
print(type(args)) # <class 'tuple'>
print(args) # ('bannanas', 'cherry')
doff("apples", 'bannanas', 'cherry')
def func(*args, **kwargs):
print(args, kwargs) # (1, 2, 'a') {'x': 1, 'y': 2, 'z': 3}
print(type(args), type(kwargs)) # <class 'tuple'> <class 'dict'>
func(1, 2, "a", x=1, y=2, z=3)