1.不固定参数函数的定义:
def foo(*args): print args foo(1,2)返回:(1,2)2.def foo(**args): print args foo(a=1,b=2,c=3)返回:{'a': 1, 'c': 3, 'b': 2},Note:这个是key-value类型的参数,和上面的不同
2.
def foo(x,y=2,*args,**kargs): print 'x==>',x print 'y==>',y print 'args is', args print 'tuple args is',kargs foo(1,3,4,5,a=1,b=2,c=3)
返回:
x==> 1 y==> 3 args is (4, 5) tuple args is {'a': 1, 'c': 3, 'b': 2}