书《Python核心编程(第二版).pdf》,作者:Wesley J. Chun
在函数调用中使用*和**符号来指定元组tuple和字典dict。
def newfoo(arg1, arg2, *nkw, **kw): """display regular args and all variable args""" print('arg1 is: ', arg1) print('arg2 is: ', arg2) for eachNKW in nkw: print('additional non-keyword arg: ', eachNKW) for eachKW in kw.keys(): print("additional keyword arg '%s': %s" % (eachKW, kw[eachKW])) # newfoo('wolf', 3, 'projects', freud=90, gamble=96) # newfoo(2, 4, *(6, 8), **{'foo': 10, 'bar': 12})