1、**的作用首先是一个简单的例子,定义一个带有3个参数的函数def fun(a, b, c): print a, b, c这个函数可以使用多种方法进行调用fun(1,2,3)输出:1 2 3 fun...:3}fun(1,2,**d) d={'a':7,'b':8,'c':9}fun(**d)#错误的例子d={'a':1, 'b':2, 'c':3, 'd':4}fun(**d)上面的代码会报错:TypeError...def fun(a, **kwargs): print "a is", a print "We expect kwargs 'b' and 'c' in this function"...print "b is", kwargs['b'] print "c is", kwargs['c']fun(1, b=3, c=5)输出是:a is 1 We expect...kwargs 'b' and 'c' in this functionb is 3c is 5错误的调用:fun(1, b=3, d=5)a is 1We expect kwargs 'b' and