>>> list(range(3, 6)) # normal call with separate arguments
[3, 4, 5]
>>> args = [3, 6]
>>> list(range(*args)) # call with arguments unpacked from a list
[3, 4, 5]
in the same fashion, dictionaries can deliver keyword arguments with the **-operator:以同样的方式,字典可以用**运算符传递关键字参数 即**-操作符来解包参数:
>>> def parrot(voltage, state='a stiff', action='voom'):
... print(-- this parrot wouldn't, action, end=' ')
... print(if you put, voltage, volts through it., end=' ')
... print(e's, state, !)
...
>>> d = {voltage: four million, state: bleedin' demised, action: voom}
>>>parrot(**d)
-- this parrot wouldn't voom if you put four million volts through it. e's bleedin' demised !