#Author:Winter Liu
importosimportreimportxlwtdefcheck_file(file_path):
os.chdir(file_path)print(os.path.abspath(os.curdir))
all_file=os.listdir()
files=[]for f inall_file:ifos.path.isdir(f):
files.extend(check_file(file_path+'\\'+f))
os.chdir(file_path)else:
files.append(f)returnfiles
file_list= check_file("C:\迅雷下载")
book=xlwt.Workbook()
sheet= book.add_sheet('文件名')
i=0for data infile_list:
sheet.write(i,0,data)
i+= 1book.save('文件名搜索.xls')
s= ' '.join(file_list)
res_1= re.findall(r'\D\d{8}\D',s)print(res_1)