擅长:python、mysql、java
<p>请阅读有关从模块上的<a href="https://docs.python.org/2/tutorial/modules.html#packages" rel="nofollow">python documentation</a>导入的信息。在</p>
<p>在这种情况下,一种可能的解决方案是在包中使用相对导入:</p>
<p>也就是说,在<code>logic/parsers/__init__.py</code>中,使用:</p>
<pre><code>from .abstract_parser import abstract
from .time_parser import _timeInfo
</code></pre>
<p>在<code>abstract_parser.py</code>中:</p>
^{pr2}$
<p>这应该让<code>parsers/__init__.py</code>找到<code>abstract_parser</code>模块和<code>time_parser</code>模块。在</p>
<p>python导入系统有很多陷阱,您可以落入这些陷阱中。<a href="http://python-notes.curiousefficiency.org/en/latest/python_concepts/import_traps.html" rel="nofollow">This blog post</a>作者nickcoghlan描述了其中的许多,我个人认为如果您计划开发一个包,这是一本必读的书。在</p>