Python函数导入层次结构

时间:2019-08-01 04:27:30

标签: python python-3.x python-import

我有以下项目:

- root
  -addons
    -module1.py (contains the function func1)
  -folder1
    -module2.py (contains func2 which needs to use func1)
main.py (contains call to func2)

我正在尝试运行main.py

我是这样导入的:

from addons.module1 import func1
from folder1.module2 import func2

但是当我在main中调用func2时,我会得到

  

未定义名称'func1'

如何通过导入魔术确保func2知道func1

我正在使用python 3.7。

0 个答案:

没有答案
相关问题