我正在使用流行的百万首歌曲数据集,数据包含在几个嵌套的子文件夹中。所有文件均为.h5文件。我正在使用os库将数据导入python,但是它停在父文件夹中,并且不会循环获取所有数据。我不确定如何建立循环来实现这一目标。
entries = os.listdir("/Users/katherineperkins/Downloads/MillionSongSubset/data")
for filename in os.listdir(entries):
if filename.endswith(".h5") or filename.endswith(".py"):
# print(os.path.join(directory,filename))
continue
else:
continue
使用所有找到的代码段,我最终遇到以下错误:
listdir: path should be string,bytes,os.PathLike,integer or None,not list