要进行仿真
from X import *,必须导入模块,然后将适当的名称合并到全局名称空间中。
# get a handle on the modulemdl = importlib.import_module('X')# is there an __all__? if so respect itif "__all__" in mdl.__dict__: names = mdl.__dict__["__all__"]else: # otherwise we import all names that don't begin with _ names = [x for x in mdl.__dict__ if not x.startswith("_")]# now drag them inglobals().update({k: getattr(mdl, k) for k in names})

![如何使用importlib从模块导入*?[重复] 如何使用importlib从模块导入*?[重复]](http://www.mshxw.com/aiimages/31/646504.png)
