1. 程式人生 > >Python 批量處理特定格式文件

Python 批量處理特定格式文件

mat walk pytho div app append spa 調用 [1]

 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)

Python 批量處理特定格式文件