擅长:python、mysql、java
<p>用这个代替</p>
<pre><code>from . import base
</code></pre>
<p><strong>编辑</strong></p>
<P>考虑下面的例子:</P>
<pre><code>└── foo
├── __init__.py
├── module_bar.py
└── module_foo.py
$ cat foo/module_bar.py
from . import module_foo
print(module_foo.load())
$ cat foo/module_foo.py
def load():
print("module foo is loaded")
$ python
Python 3.8.2 (default, May 4 2020, 20:05:11)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import foo.module_bar
module foo is loaded
</code></pre>
<p>这意味着,无论何时从目录导入模块,目录中的导入都应以<code>.</code>开始</p>