Python runpy 模块,_run_module_as_main() 实例源码

我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用runpy._run_module_as_main()

项目:sikulpy    作者:shish    | 项目源码 | 文件源码
def run(folder):
    folder = os.path.abspath(folder)
    module = os.path.basename(folder).replace(".sikuli", "")
    # print("Running %s from %s" % (module, folder))
    sys.path.append(folder)
    sys.path.append(os.path.dirname(folder))  # FIXME: adding parent is unofficial
    Settings.ImagePaths.append(folder)
    try:
        runpy._run_module_as_main(module)
        # mod = __import__(module)
    except KeyboardInterrupt:
        pass