【发布时间】:2019-05-03 21:17:15
【问题描述】:
我的文档结构如下:
root
|src
|__init__.py
|util.py
|mymodule.py
|__init__.py
|test.py
init.py 都是空的
在 util.py 中有一系列实用函数,例如 a()、b()、c()。
在 mymodule.py 我有:
from util import a, b, c
def somefunc():
# some stuff
a()
# more stuff
在 test.py 我有:
from src.mymodule import somefunc
我希望能够在 src 之外引用这些模块,但我收到错误“mymodule.py 中的错误来自 util import a, b, c, ModuleNotFoundError: No module named 'util'”
【问题讨论】:
标签: python python-3.x