#!/usr/bin/env python#-*- coding: utf-8 -*-
importxlsxwriterimportosimportwin32com.client as win32defexcleCount_passenger(file_path):#定义输出的文件路径在原始文件的路径的同级目录新建一个outfile
file_list =[]
out_file_path= os.path.join(os.path.abspath(os.path.dirname(file_path)+os.path.sep+"."), 'out_file')if notos.path.exists(out_file_path):
os.makedirs(out_file_path)for root, dirs, files inos.walk(file_path):for name infiles:
excle_file_name=os.path.join(file_path, os.path.join(root, name))if name.endswith('.xls') or name.endswith('.xlsx'):#print(excle_file_name)
file_list.append(excle_file_name)#打开excle
excel= win32.Dispatch("Excel.Application")
excel.Visible=False
excel.DisplayAlerts=False
xlBook=excel.Workbooks.Open(file_list[0])
sheetname= xlBook.Sheets(1).Name#print ex
sht=xlBook.W