<p>我知道这个论点是琐碎的,在很多文章中都有论述,但我读过,我仍然不清楚如何将文件夹中的内容视为包。。。
以这个例子为例(我知道有*rc文件会产生相同的结果..)
我已经定义了一个名为<code>basequalityplot</code>的基类,在这个基类中,我定义了在类名质量图中定制图(其中我定义了公共参数(稳定或变量)、更新rcParams)所需的所有东西,其中包含基类和更多…:
名为basequalityplot.py的完整类报告在:<a href="https://paste.pound-python.org/show/RiSewRM0Y45ORkIg8dOE/" rel="nofollow noreferrer"><img src="https://paste.pound-python.org/show/RiSewRM0Y45ORkIg8dOE/" alt="here"/></a></p>
<p>基模块包含派生类。。。经常重复。。我只报告一个:</p>
<pre><code>import sys
import os
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
from matplotlib.axes import Axes
from cycler import cycler
from matplotlib import cm
from collections import OrderedDict
from matplotlib.ticker import AutoMinorLocator
from basequalityplot import BasePlot
#######################################################################
#######################################################################
class Standard(BasePlot):
def __init__(self,**kwargs):
self.parameters = kwargs
if 'box' not in self.parameters.keys():
self.parameters['box'] = '#AAAAAA'
if 'axeslabel' not in self.parameters.keys():
self.parameters['axeslabel'] = '#AAAAAA'
if 'axes.linewidth' not in self.parameters.keys():
self.parameters['axes.linewidth'] = 0.7
if 'xtickcolor' not in self.parameters.keys():
self.parameters['xtickcolor'] ='#AAAAAA'
if 'ytickcolor' not in self.parameters.keys():
self.parameters['ytickcolor'] = 'gray'
if 'gridcolor' not in self.parameters.keys():
self.parameters['gridcolor'] = 'gray' #'#AAAAAA' #'#dddddd'
if 'font' not in self.parameters.keys():
self.parameters['font'] = 'serif'
if 'fontstyle' not in self.parameters.keys():
self.parameters['fontstyle'] = 'italic'
if 'fontsize' not in self.parameters.keys():
self.parameters['fontsize'] = 10.0
if 'legendfontsize' not in self.parameters.keys():
self.parameters['legendfontsize'] =10.0
if 'legendEdgeColor' not in self.parameters.keys():
self.parameters['legendEdgeColor'] = '#AAAAAA' #'#dddddd'
if 'scheme' not in self.parameters.keys():
self.parameters['scheme'] = 'nb'
if 'cycle' not in self.parameters.keys():
self.parameters['cycle'] = self.cycle('0')
if 'axes.linewidth' not in self.parameters.keys():
self.parameters['axes.linewidth'] = 0.7
if 'grid.dashes' not in self.parameters.keys():
self.parameters['grid.dashes'] = (5,5)
if 'grid.linestyle' not in self.parameters.keys():
self.parameters['grid.linestyle'] = '--'
if 'linestyle' not in self.parameters.keys():
self.parameters['linestyle'] = self.linestyles('paper')
if 'cycle' not in self.parameters.keys():
self.parameters['cycle'] = self.cycle('0')
if 'grid.alpha' not in self.parameters.keys():
self.parameters['grid.alpha'] = '1'
if 'grid.linewidth' not in self.parameters.keys():
self.parameters['grid.linewidth'] = 0.7
self.parameters.update(kwargs)
super().__init__(**self.parameters)
</code></pre>
<p>嗯。。。我想在同一个目录中包含<code>basequalityplot.py</code>和<code>qualityplot.py</code>(其中qualityplot是包含我要使用的类的模块)。。在这种情况下,我只报告了标准的一个)</p>
<p>我试图创建一个名为<code>qualityPlot</code>的文件夹</p>
<p>然后从子目录中的脚本尝试<code>import qualityPlot</code>,就像导入packjage一样。。但这行不通。。。。
有人能帮我吗</p>