python使用字典给出的参数计算函数

Cod*_*lus 3 python dictionary functional-programming

使用python如何使用其关联参数来评估函数字典.更具体地说,键是函数,值是参数列表.

例如,考虑字典:

{f1: [a, b, c], f2: [q], f3: [5, c]}
Run Code Online (Sandbox Code Playgroud)

我将如何迭代计算的函数:

f1(a, b, c)
f2(q)
f3(5, c)
Run Code Online (Sandbox Code Playgroud)

小智 8

for func, args in the_dictionary.items():
    func(*args)
Run Code Online (Sandbox Code Playgroud)