1.序列参数:所有参数作为一个列表传入
>>> def fun(a,b,c):
print('value of a is {}'.format(a))
print('value of b is %s'% b)
print('value of c is {}'.format(c))
>>> fun('one','two','three')
value of a is one
value of b is two
value of c is three
>>> l = ['one','two','three']
>>> fun(l)
Traceback (most recent call last):
File "<pyshell#21>", line 1, in <module>
fun(l)
TypeError: fun() missing 2 required positional arguments: 'b' and 'c'
>>> fun(*l)
value of a is one
value of b is two
value of c is three
2.字典参数:所有参数作为一个字典传入
>>> def fun(a,b,c):
print('value of a is {}'.format(a))
print('value of b is %s'% b)
print('value of c is {}'.format(c))
>>> d = {'a':'one','b':'two','c':'three'}
>>> fun(*d)
value of a is a
value of b is b
value of c is c
>>> fun(**d)
value of a is one
value of b is two
value of c is three