python学习之动态导入

动态导入:(通过字符串导入模块)
module_t=__import__('m1.t') 直接定位到m1顶层模块名,t文件下test1方法
print(module_t)
module_t.t.test1()

import importlib
m=importlib.import_module('m1.t') 直接定位到m1模块下t
print(m)
m.test1()

原文地址:https://www.cnblogs.com/jinpingzhao/p/12735538.html