相关疑难解决方法(0)

2149
推荐指数
17
解决办法
65万
查看次数

如何在Python中将列表扩展为函数参数

是否有语法允许您将列表扩展为函数调用的参数?

例:

# Trivial example function, not meant to do anything useful.
def foo(x,y,z):
   return "%d, %d, %d" %(x,y,z)

# List of values that I want to pass into foo.
values = [1,2,3]

# I want to do something like this, and get the result "1, 2, 3":
foo( values.howDoYouExpandMe() )
Run Code Online (Sandbox Code Playgroud)

python arguments

138
推荐指数
4
解决办法
9万
查看次数