更新时间:2021-12-22 22:56:13
一个人可以告诉python通过sys.path
在哪里寻找模块.我有一个这样的项目结构:
One can tell python where to look for modules via sys.path
. I have a project structure like this:
project/
│
├── src/
│ └── my_module/
│ ├── __init__.py
│ └── helpers.py
├── notebooks/
│ └── a_notebook.ipynb
...
我能够像这样加载模块:
I was able to load the module like so:
import sys
sys.path.append('../src/')
from my_module import helpers
一个人应该可以从任何地方加载该模块.
One should be able load the module from wherever they have it.