Ter*_*ado 1 python function shortcut python-3.x
我有一段代码看起来像这样:
myfunction(a, b, c)
myfunction(d, e, f)
myfunction(g, h, i)
myfunction(j, k, l)
Run Code Online (Sandbox Code Playgroud)
自变量的数量不变,但是每次必须使用不同的值连续调用该函数。这些值不会自动生成,而是手动输入。是否有内联解决方案来执行此操作而不创建函数来调用此函数?就像是:
myfunction(a, b, c)(d, e f)(g, h, i)(j, k, l)
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏。提前致谢!
简单,使用元组拆包
tripples = [('a', 'b', 'c'), ('d', 'e', 'f'), ('g', 'h', 'i'), ('j', 'k', 'm')]
for tripple in tripples:
print(myfunction(*tripple))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3427 次 |
| 最近记录: |