Q:文件能正常读取和处理,在保存时出现报错如下
FileNotFoundError: [Errno 2] No such file or directory: '/home/(不重要的路径)/test/00001/augmented1.wav'
路径='savepath'/'file'
相关代码:
for file in files:dataname = path + filesavename = savepath + fileif "augmented" in dataname:shutil.move(dataname, savename)
path='/home/(不重要的路径)/test/00001/' files= os.listdir(path) savepath='/home/(不重要的路径)/test/00001/'
A:savepath只能是已经存在的路径,在相应的位置新建文件夹后该报错消失(我是猪比吗?)
TIP2:使用path+file的组合方式的时候记得path的最后一级文件夹后面要加"/",不然也会报错,因为你的dataname会变成
'/home/(不重要的路径)/train/00001filename'#即train文件夹下的00001file
而不是
'/home/(不重要的路径)/train/00001/filename'#train文件夹下的00001子文件夹中的file