1 #批量对文件夹下的'.mat'进行处理 2 3 def file_name(file_dir,suff): 4 L=[] 5 for root, dirs, files in os.walk(file_dir): 6 for file in files: 7 if os.path.splitext(file)[1] == suff: 8 L.append(os.path.join(root, file)) 9 return L 10 11 #调用 12 file_dir='D:\sa' 13 suff='.mat' 14 L=[] 15 L=file_name(file_dir,suff)