【发布时间】:2021-10-23 20:24:06
【问题描述】:
文件组织
./helper.py
./caller1.py
./sub_folder/caller2.py
从caller1.py导入helper.py就可以了。
caller1.py
from helper import hello
if __name__ == '__main__':
hello()
但是当使用 完全相同的代码从./sub_folder/caller2.py 导入时,我得到了错误...
ModuleNotFoundError: No module named 'helper'
由于项目很大,我想将文件组织到子文件夹中。
【问题讨论】:
标签: python python-import subdirectory project-organization