如何在python上使用importlib导入多个不同的导入?

问题描述

我有一个python文件,开始有很多导入语句,例如

test_c:
  stage: test
  script:
    - echo "This job tests something. It will only run when all jobs in the"
    - echo "build stage are complete."
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'

假设我有一个名为a.py的文件,而a.py使用from enum import auto 。 有没有一种方法可以创建一个名为from enum import auto的单独文件,该文件可以导入我使用importlib指定的所有模块?

我尝试了以下失败的尝试:

imports.py

(modules是一个数组,将保存导入的模块)

错误提示

modules.append(importlib.import_module(auto,Package=enum))

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)