Skip to main content
 首页 » 编程设计

python之如何在 python 中提取方法调用的数组条目

2025年05月04日12duanxz

我有一个数组,应该扩展它以向函数调用提供多个参数 - 如下所示:

def x(a,b,c): 
    print "%d %d %d" %(a,b,c) 
 
t = [1,2,3] 
 
x(t[:])  # Will not work - this is only one value 

基本上我正在寻找相当于

的 python
 :_* 

在 scala 中构建

请您参考如下方法:

它叫做 unpacking :

>>> def x(a, b, c): 
...     print(a, b, c) 
... 
>>> l = [1, 2, 3] 
>>> x(*l) 
(1, 2, 3)