我有一个 python 类,如下所示。
class copyingfiles():
@staticmethod
def __init__(self, x=[], y=[], z=None, i=None):
self.x = x
self.y = y
self. z = z
self.i= i
@staticmethod
def mover(self):
x = self.x
y= self.y
z = self.z
i= self.i
for sam in x.keys():
for pids in y:
PID = pids.split('_')[1]
if sam in pids:
destination = z + "/rep/" + "study/" + id + "/" + sam + "/rh/"+ "fg/"
if not os.path.isdir(destination):
pathlib.Path(destination).mkdir(parents=True, exist_ok=True)
for files in fnmatch.filter(os.listdir(i), pat="*.gz"):
if sam in files:
shutil.copy(os.path.join(i,files), os.path.join(destination,files))
return(destination)
其中 x=[], y=[] 是字典,z=None, I=None 是路径。
我尝试在我的班级中调用该函数copyingfiles,如下所示,
testInstance = copyingfiles()
testInstance.mover(x, y,z,i)
它抛出以下错误,
TypeError Traceback (most recent call last)
<ipython-input-50-7da378685d71> in <module>
----> 1 testInstance = copyingfiles()
2 testInstance.mover(x, y,z,i)
TypeError: __init__() missing 1 required positional argument: 'self'
我对python类有理论上的理解。然而,从未尝试过。所以任何帮助都会很棒!
噜噜哒
慕容708150
莫回无
慕田峪4524236
随时随地看视频慕课网APP
相关分类