理解Python的*args, **kwargs

1 # coding=utf-8
2 def speak(*args, **kwargs):
3     print args, kwargs
4     
5     
6 a = 1
7 b = 2
8 c = 3
9 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}

posted @ 2014-09-15 11:10  Mx.Hu  阅读(239)  评论(0编辑  收藏  举报