首页 > 代码库 > 理解Python的*args, **kwargs

理解Python的*args, **kwargs

1 # coding=utf-82 def speak(*args, **kwargs):3     print args, kwargs4     5     6 a = 17 b = 28 c = 39 speak(a, b, c, b, c, a, c, a, b, d=a, e=b, f=c)

output:

(1, 2, 3, 2, 3, 1, 3, 1, 2) {‘e‘: 2, ‘d‘: 1, ‘f‘: 3}

理解Python的*args, **kwargs