python - 在 Python (3.x) 中使用不同的参数连续多次调用函数?

标签 python python-3.x function shortcut

我有一段代码,如下所示:

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/

相关文章:

python - 使用条件对数组进行排序的有效方法

python - 相互引用 Enum 成员

function - 将变量 []interface{} 转换为变量 ...interface{} in go

mysql - 创建一个在 MYSQL 中起作用的函数

c - 将函数的地址获取到C中的结构中

python - 在进一步的 url 中抓取

python - 在 Pandas python 中聚合数据

python - Django 中 choicefield 的 HTML 标签

python - asyncio Queue.get 延迟

python - 如何检测 if 语句何时退出