def import_arbitrary(fileName, modName):
"""
Returns a module reference.
This function acts like a Python import statement, but it will
import an arbitrary Python file located at any path.
"""
importlib.invalidate_caches()
loader = ilmac.SourceFileLoader(modName.replace('.', '_'), fileName)
spec = ilutil.spec_from_loader(loader.name, loader)
mod = ilutil.module_from_spec(spec)
loader.exec_module(mod)
return mod
# End import_arbitrary
评论列表
文章目录