python中args,*args,**kwargs的区别

args 表示参数是一个变量

*args 表示参数是一个tuple

**kwargs 表示参数是一个dict

 

比如

def function(arg,*args,**kwargs):
      print(arg,args,kwargs)
function(6,7,8,9,a=1, b=2, c=3)

结果为 6 (7, 8, 9) {'a': 1, 'b': 2, 'c': 3}

 

posted @ 2016-02-16 23:48  tonglin0325  阅读(568)  评论(0编辑  收藏  举报