我正在尝试使用过滤器搜索一系列文件夹/子文件夹,然后将结果写出来。如果将结果写入同一个数组,它可以工作,但无法弄清楚如何将匹配项定向到特定数组。感谢您的任何建议。
matchlist = [ ['*.csv'], ['*.txt'], ['*.jpg'], ['*.png'] ]
filearray = [ [],[],[],[] ]
for root, dirs, files in os.walk(folderpath):
for file in files:
for entry in matchlist:
if file.endswith(entry):
filearray[TheAppropriateSubArray].append(os.path.join(root, file))