Python args kwargs 技巧

def f(*args):
    print(args)

a=[1, 2, 3]
f(a)
f(*a)

运行结果:
([1, 2, 3],)
(1, 2, 3)
def f(**kwargs):
    print(kwargs)

f(name='klvchen', age=28)
f(**{'name':'klvchen', 'age': 28})

运行结果:
{'name': 'klvchen', 'age': 28}
{'name': 'klvchen', 'age': 28}
原文地址:https://www.cnblogs.com/klvchen/p/8743853.html