项目模块化
.
├── proto
│ ├── mat.py
├── utils
│ └── mat_mul.py
└── src
└── main.py
node2:/root/python3/test2#ls
proto src utils
node2:/root/python3/test2#tree
.
├── proto
│ ├── __init__.py
│ └── mat.py
├── src
│ └── main.py
└── utils
├── __init__.py
└── mat_mul.py
3 directories, 5 files
import sys
sys.path[0] = '/home/ubuntu/workspace/your_projects'
方案1:
node2:/root/python3/test2/src#cat main.py
# src/main.py
import sys
sys.path[0]='/root/python3/test2'
from proto.mat import Matrix
from utils.mat_mul import mat_mul