擅长:python、mysql、java
<p>您应该使用<code>importlib.import_module</code>,不建议在解释器外部使用<code>__import__</code>。</p>
<p>在<code>__import__</code>的docstring中:</p>
<blockquote>
<p>Import a module. Because this function is meant for use by the Python
interpreter and not for general use it is better to use
importlib.import_module() to programmatically import a module.</p>
</blockquote>
<p>它还支持<a href="https://docs.python.org/2.5/whatsnew/pep-328.html" rel="noreferrer">relative imports</a>。</p>