小编Ksa*_*neK的帖子

如何将列表元素作为参数传递

我想将list的元素作为函数参数传递,如下所示:

def foo(a,b,c):
    #do something
list=[1,2,3]
foo(list)
Run Code Online (Sandbox Code Playgroud)

我不能使用foo(list [0],list [1],list [2]),因为我不知道有多少元素列表有多少参数函数需要

看看这段代码中的输入函数:http://pastebin.com/ajDrFmzr

现在它只传递1个参数(列表),我想把它作为少数参数传递

python

3
推荐指数
1
解决办法
5636
查看次数

标签 统计

python ×1