python:使用函数名称通过字符串调用function(dictionary)

时间:2019-12-12 19:42:35

标签: python-3.x function dictionary arguments call

def test(dictionary):
    print(dictionary)

t = 'test'
d = {'a': 341, 'b': 'vhjalj'}

如何使用t和d来调用test(d)?例如,我想通过t(d)调用test(d)。

我已经尝试过eval(t +'('+ d +')'),但是python解释说一个'只能将str(而不是“ dict”)连接到str'。

0 个答案:

没有答案
相关问题