*arg**kwargs 只是为了方便并没有强制使用它们。

    *args 是不定长参数,它可以表示输入参数是不确定的,可以是任意多个 **kwargs 是关键字参数,赋值的时候是以键值对的方式,参数可以是任意多对在定义函数的时候.

    当你不确定你的函数需要传递多少参数时,你可以用*args

    例如,它可以传递任意数量的参数:

    1. def func(*args):
    2. for count, thing in enumerate(args):
    3. print('{0} {1}'.format(count, thing))
    4. # 0 apple
    5. # 1 banana
    6. # 2 peach
    7. # 3 watermelon
    8. # 4 pear
    9. func('apple','banana','peach','watermelon','pear')

    相似的,**kwargs允许你使用没有事先定义的参数名:

    1. def fucn(**kwargs):
    2. for name, value in kwargs.items():
    3. print('{} == {}'.format(name, value))
    4. # apple == 1
    5. # banana == 2
    6. # pear == 3
    7. fucn(apple='1',banana='2',pear='3')

    也可以混着用,命名参数首先获得参数值然后所有的其他参数都传递给*args**kwargs,命名参数在列表的最前端。例如:

    1. def func(string, **kwargs):

    *args**kwargs 可以同时在函数的定义中,但是*args 必须在**kwargs前面。调用函数时,也可以使用***的语法。

    1. def func(a, b, c):
    2. print('a={},b={},c={}'.format(a,b,c))
    3. #a=1,b=2,c=3
    4. ff = [1,2,3]
    5. func(*ff)

    它可以传递列表(元组)的每一项并把它们解包。注意必须与他们在函数里的参数相吻合。也可以在函数定义或者函数调用时用*