我需要这方面的帮助。如何将字符串转换为变量/对象/实例名称,因为我不知道如何对其进行分类。
假设我的代码是:
a = {}
b = {}
class Test:
def getKeys(self, var):
return var.keys() #where var refers to the dictionary and its a string initially
我已经很久没有使用 Python 做过任何事情了,但我确实记得曾经遇到过这个问题。我建议你看看eval()功能。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)