将String转换为Object name

Nat*_*ume 6 python object instance

我需要这方面的帮助.如何将字符串转换为变量/对象/实例名称,因为我不知道如何对其进行分类.
假设我的代码是:

a = {}
b = {}

class Test:
    def getKeys(self, var):
        return var.keys() #where var refers to the dictionary and its a string initially
Run Code Online (Sandbox Code Playgroud)

小智 6

自从我用Python做过任何事情以来,这一直都是一生,但我确实记得曾经遇到过这个问题。我建议您调查一下该eval()功能。