Python Importlib模块
通过字符串导入模块,动态导入模块,3种方式,记录如下:
方式一:12os1 = __import__('os')os1.path.join <==> from os.path import join
方式二:123import impos2 = imp.load_module('os',*imp.find_module('os'))os2.path.join <==> from os.path import join
方式三:123module = importlib.import_module('os')os_path = getattr(module,'path')os_path.join <==> from os.path import join