擅长:python、mysql、java
<p>您当前使用的是所谓的<strong>隐式相对导入。</strong>在python3.x中它被弃用,这在<a href="https://www.python.org/dev/peps/pep-0008/#imports" rel="nofollow noreferrer">PEP 8</a>中提到。你知道吗</p>
<p>您仍然可以使用相对导入;它只需要使用下面描述的带有前导点的<a href="https://docs.python.org/3.6/tutorial/modules.html#intra-package-references" rel="nofollow noreferrer">syntax</a>:</p>
<blockquote>
<p>These imports use leading dots to indicate the current and parent packages involved in the relative import.</p>
</blockquote>
<pre><code># Relative
from .test1 import testFunc
# Absolute
from paquete.test1 import testFunc
</code></pre>
<p>也是<a href="https://docs.python.org/3.0/whatsnew/3.0.html#removed-syntax" rel="nofollow noreferrer">reference</a>-</p>
<blockquote>
<p>The only acceptable syntax for relative imports is <code>from .[module] import name</code>. All import forms not starting with <code>.</code> are interpreted as absolute imports. (PEP 0328).</p>
</blockquote>