📜  从变量创建字典并给出名称 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:28.669000             🧑  作者: Mango

代码示例1
mydict = NewClass()
vars = ['a', 'b', 'c']
for v in vars: 
    setattr(mydict, v, eval(v)) 

mydict.__dict__
{'a': 9, 'b': ['hello', 'world'], 'c': (True, False)}