In C++/C,
fn(a, b)
fn(a, b, c, d, ...)
I handed over several factors by overloading or ...
like this, but I wonder how it can be used in Python.
Use the *
operator if you do not accept the keyword factor.
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)
As you can see, all the factors are returned to the tuple type.
For more information, what are the ** and * in the parameters?Please refer to
© 2025 OneMinuteCode. All rights reserved.