是。
如果你不理会关键字参数,这很简单并且可以工作:
def manyArgs(*arg): print "I was called with", len(arg), "arguments:", arg>>> manyArgs(1)I was called with 1 arguments: (1,)>>> manyArgs(1, 2, 3)I was called with 3 arguments: (1, 2, 3)
如你所见,Python将为你提供一个包含所有参数的元组。
对于关键字参数,你需要将其作为单独的实际参数接受,如
Skurmedel的
answer所示。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)