字典是从配置文件生成的:
dict_1 = {
'type1' : 'function1()',
'type2' : 'function2()',
'type3' : 'function3()'
}
Run Code Online (Sandbox Code Playgroud)
变量x包含此字典中的任何键.我试着按如下方式调用函数:
dict_1[x]
Run Code Online (Sandbox Code Playgroud)
有没有人知道运行此语句的exec函数的替代方法?