这是我的文件夹结构:
src/
__init__py
Lowlevel/
__init__.py
ModuleToCheck.Py
Test/
__init__.py
ModuleToCheck_test.py
(__init__.py
为空文件)
现在我想导入ModuleToCheck.py
到ModuleToCheck_test.py
我如何才能做到这一点而不在sys.path
上添加任何内容?在
更新:
from ..Lowlevel import ModuleToCheck
导致:
^{pr2}$
Tags:
以下内容来自http://docs.python.org/tutorial/modules.html#intra-package-references
您将模块
ModuleToCheck_test.py
作为主模块运行,因此出现异常。在一种解决方案是在
src
目录中创建一个test.py
模块,其中包含以下内容:然后可以使用
python test.py
运行该模块相关问题 更多 >
编程相关推荐