擅长:python、mysql、java
<p>在Python中使用模块</p>
<ul>
<li>确保目录中存在<code>__init__.py</code>文件(注意下划线)</li>
<li>请注意,文件夹名和文件名都是模块的一部分</li>
<li>确保Python会找到路径(比如PYTHONPATH)</li>
</ul>
<p>在你的例子中</p>
<p><code>from basequalityplot import BasePlot</code></p>
<p>这需要在当前目录(或者直接在python路径上的其他地方,或者编译版本)中找到一个文件basequalityplot.py。在该文件中,它希望找到类BasePlot</p>
<blockquote>
<p>I would like to contain basequalityplot.py and qualityplot.py in the same directory (where qualityplot is the module that contain the class that I want use .. in this case I've report just the standard one)</p>
<p>I've tried to create a folder named qualityPlot</p>
</blockquote>
<p>您在这里描述的内容与示例代码不太匹配。如果你有一个文件夹结构</p>
<pre><code>qualityPlot/
__init__.py
basequalityplot.py
qualityplot.py
</code></pre>
<p>我希望import语句</p>
<pre><code>from qualityPlot.qualityplot import BasePlot
</code></pre>
<p>在Python教程6.4中有一个有用的例子
<a href="https://docs.python.org/3/tutorial/modules.html#packages" rel="nofollow noreferrer">https://docs.python.org/3/tutorial/modules.html#packages</a></p>