擅长:python、mysql、java
<p>发件人:
<a href="https://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path?lq=1">How to import a module given the full path?</a></p>
<p>我的目录布局:</p>
<pre><code>/my_package
/__init__.py
/testfile.py
/my_module
/__init__.py
</code></pre>
<p>方法1:</p>
^{pr2}$
<p>或限制进口:</p>
<pre><code>import sys
import os
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
from my_module import function1
function1()
</code></pre>