#创建文件
file = Workbook(encoding='utf-8')#创建sleettableTotalTime = file.add_sheet('TotalTime')#每列给出名称tableTotalTime.write(0,0,'TotalTime')
TotalTimefpath = r'C:\Users\XXXX\Desktop\packet\autoScript\TotalTime.log'
#打开文件并读取f = open(TotalTimefpath,'r')line = f.readlines()len = 1 for item in line: #转为list list = item.split( ) TotalTime = list[1] print u"TotalTime耗时为:"+TotalTime+"ms" # print Cpu 并存入excel为整数类型 tableTotalTime.write(len,0,int(TotalTime)) len = len + 1f.close()#保存excel并命名file.save('TotalTime.xlsx')