def test_kw(a,b,**kw):
print("addddd",a*b)
print(kw)
params = {"y":19,"a":1,"b":2,"c":3,"d":4}
test_kw(**params)
输出:
addddd 2
{'y': 19, 'c': 3, 'd': 4}
这样就可以进行传递;
def test_kw(a,b,c=1,**kw):
print("a:{0},b:{1},c:{2}".format(a,b,c))
print(kw)
params = {"y":19,"a":1,"b":2,"c":3,"d":4}
test_kw(**params)
输出:
a:1,b:2,c:3
{'y': 19, 'd': 4}