我有一段代码,如下所示:
myfunction(a, b, c)
myfunction(d, e, f)
myfunction(g, h, i)
myfunction(j, k, l)
参数的数量不变,但必须每次使用不同的值连续调用该函数。这些值不是自动生成的,而是手动输入的。是否有内联解决方案可以在不创建函数来调用该函数的情况下执行此操作?像这样的东西:
myfunction(a, b, c)(d, e f)(g, h, i)(j, k, l)
任何帮助表示赞赏。提前致谢!
最佳答案
简单,使用元组拆包
tripples = [('a', 'b', 'c'), ('d', 'e', 'f'), ('g', 'h', 'i'), ('j', 'k', 'm')]
for tripple in tripples:
print(myfunction(*tripple))
关于python - 在 Python (3.x) 中使用不同的参数连续多次调用函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47615999/