Python 使用列表列表中的列表作为函数调用的参数

Python 使用列表列表中的列表作为函数调用的参数,python,list,Python,List,我试图从列表中调用一个带参数的函数,问题是它将整个列表视为一个参数,即使列表中的每个列表都包含3个参数。 如何让函数将列表视为3个参数 lists = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [2, 5, 8]] def do_something(x, y, z): bla. bla. bla do_something(lists[1]) 错误消息是这样说的: TypeError: do_something() missing 2 required p

我试图从列表中调用一个带参数的函数,问题是它将整个列表视为一个参数,即使列表中的每个列表都包含3个参数。 如何让函数将列表视为3个参数

lists = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [2, 5, 8]]


def do_something(x, y, z):
    bla. bla. bla

do_something(lists[1])
错误消息是这样说的:

TypeError: do_something() missing 2 required positional arguments: 'y' and 'z'

函数接收3个参数x、y、z,您只传递了1。探索*args的用法,可能这就是您正在寻找的,您应该像这样调用您的方法;做某事(列表[1][0]、列表[1][1]、列表[1][2])