有时需要将多个参数打包成一个参数传递进函数中
比如
def foo(a,b,c):
...
...
那怎么通过一个参数传递解决呢?
办法是把参数打包成list,再通过*运算解包
talk is cheap, show me code.
args=[1,2,3]
def foo( a,b,c):
print(a)
print(b)
print(c)
foo(*args)
有时需要将多个参数打包成一个参数传递进函数中
比如
def foo(a,b,c):
...
...
那怎么通过一个参数传递解决呢?
办法是把参数打包成list,再通过*运算解包
talk is cheap, show me code.
args=[1,2,3]
def foo( a,b,c):
print(a)
print(b)
print(c)
foo(*args)