踩坑日记,参数*位置是很重要的!!!
踩坑日记,参数*位置是很重要的!!!
class Dome():
def __init__(self):
pass
def verify(self, *args, name=None, **kwargs):
print(name, args, kwargs)
def verify2(self, name=None, *args, **kwargs):
print(name, args, kwargs)
if __name__=='__main__':
dome = Dome()
arg = [1,2,3,4,5,6]
dome.verify(name='test', *arg)
dome.verify(*arg, name='test')
dome.verify2(*[1, 2])