Python导入另一个文件夹的py文件
https://stackoverflow.com/questions/16981921/relative-imports-in-python-3
import文件夹A的py文件
- 要在A目录下新建init.py文件
- 将目录加进sys.path
- 文件结构如下```
test
-- A
-- __init__.py
-- a.py
-- B
-- b.py
1
2
3
4
5
6
7
8</li>
</ul>
<h4 id="方法-1"><a href="#方法-1" class="headerlink" title="方法 1"></a>方法 1</h4><p>对b.py文件</p>
```python
import sys
sys.path.insert(0, '..')
from A import a方法2
在test下创建 ``` 然后对b.py
from test.A import a ```</p>