Python 批量处理特定格式文件

 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)

 

posted @ 2018-08-16 15:57  谁动了我的奶盖  阅读(177)  评论(0编辑  收藏  举报