在循环中用python传递多个参数

在循环中用python传递多个参数,python,arguments,function-call,multiple-arguments,Python,Arguments,Function Call,Multiple Arguments,我有一个函数,它接受元组的多个参数并进行相应的处理。我想知道是否可以在for循环中传递参数。 例如: def func(*args): for a in args: print(f'first {a[0]} then {a[1]} last {a[2]}') 然后我将调用函数作为 func(('is','this','idk'),(1,2,3),('a','3',2)) 我的问题是,是否有一种方法可以在不更改函数定义本身的情况下修改循环中的函数调用: func((i, i,

我有一个函数,它接受元组的多个参数并进行相应的处理。我想知道是否可以在for循环中传递参数。 例如:

def func(*args):
   for a in args:
      print(f'first {a[0]} then {a[1]} last {a[2]}')
然后我将调用函数作为

func(('is','this','idk'),(1,2,3),('a','3',2))

我的问题是,是否有一种方法可以在不更改函数定义本身的情况下修改循环中的函数调用:

func((i, i, i) for i in 'yes'))
以便打印:

先y后y最后y
先是e,然后是e,最后是e
先是s,然后是最后s
是,通话中有和:

func(*((i, i, i) for i in 'yes'))
也可以先使用分配给变量的生成器表达式编写:

args = ((i, i, i) for i in 'yes')
func(*args)
演示:

>>> func(*((i, i, i) for i in 'yes'))
first y then y last y
first e then e last e
first s then s last s
>>> args = ((i, i, i) for i in 'yes')
>>> func(*args)
first y then y last y
first e then e last e
first s then s last s