Python-技巧

1.sys.modules, 根据已加载的模块创建对象, 其中 page 为类名

if hasattr(sys.modules[__name__], page):
    setattr(self, page, getattr(sys.modules[__name__], page)(self))

2.hasattr, setattr, locals(), globals() 动态创建变量

3.

你可能感兴趣的:(python)