擅长:python、mysql、java
<p>尝试此布局:</p>
<pre class="lang-py prettyprint-override"><code>core/
__init__.py
functions.py
operations/
__init__.py
actions.py
test.py
</code></pre>
<p><em>注意:</em><code>__init__.py</code>文件,它们只是用来定义名称与目录名一致的包的空文件。你知道吗</p>
<p>其中<code>functions.py</code>具有核心函数定义:</p>
<pre class="lang-py prettyprint-override"><code>def core_function():
print "core function"
</code></pre>
<p>模块<code>actions.py</code>将与<code>core</code>有这样的连接:</p>
<pre class="lang-py prettyprint-override"><code>from core import functions
def simple_action():
functions.core_function()
</code></pre>
<p>在应用程序<code>test.py</code>中,可以按如下方式使用它:</p>
<pre class="lang-py prettyprint-override"><code>from core import functions
from operations import actions
functions.core_function()
actions.simple_action()
</code></pre>
<p><em>还要注意:</em>整个路径引用<code>core</code>和<code>operations</code>包,而不是相对的,也就是说,如果您有<code>lab.sci.core</code>结构,那么您应该在<code>test.py</code>应用程序和<code>actions.py</code>模块中使用<code>from lab.sci.core</code>和<code>from lab.sci.operations</code>import命令。你知道吗</p>