
https://stackoverflow.com/questions/16981921/relative-imports-in-python-3
- 要在A目录下新建init.py文件
- 将目录加进sys.path
- 文件结构如下
1
2
3
4
5
6test
-- A
-- __init__.py
-- a.py
-- B
-- b.py
方法 1
对b.py文件
1 |
import sys |
方法2
在test下创建
1 |
|

https://stackoverflow.com/questions/16981921/relative-imports-in-python-3
1 |
test |
对b.py文件
1 |
import sys |
在test下创建
1 |
|
近期评论