如果在定义函数时,*代表收集参数,**代表收集关键字参数

def myprint(*params):
    print(params)

myprint(1, 2, 3) # (1, 2, 3)

def myprint2(**params):
    print(params)

myprint2(x=1,y=2,z=3)  # {'x': 1, 'y': 2, 'z': 3}

如果在调用函数时,*和**都是分配参数用的,一个*是分配元组,两个*是分配字典

def myprint(x,y):
    print(x)
    print(y)

params=(1,2)
myprint(*params)

params={'x':1,'y':2}
myprint(**params)
09-09 07:33