由于log日志比较记录的事件比较多,很难直观分析自己想要的数据信息,因此就想把log中的有用信息提取出来,便于分析:
#coding=utf-8
import re
import os
import time
import xlwt
import datetime
path = r'C:\Users\qxrxxxx\Desktop\log'
downloadtime = time.strftime('%Y_%m_%d')
filename = 'NotificationTest_' + downloadtime + '.xls'
workbook = xlwt.Workbook(encoding='ascii')
worksheet = workbook.add_sheet('Comment')
workbook.save(filename)
font = xlwt.Font() # Create the Font
font.bold = True
font.colour_index = 1
font.height = 0x00C8 # C8 in Hex (in decimal) = 10 points in height.
style = xlwt.XFStyle() # Create the Style
style.font = font # Apply the Font to the Style
pattern = xlwt.Pattern() # Create the Pattern
pattern.pattern = xlwt.Pattern.SOLID_PATTERN # May be: NO_PATTERN, SOLID_PATTERN, or 0x00 through 0x12
pattern.pattern_fore_colour = 23 # May be: 8 through 63. 0 = Black, 1 = White, 2 = Red, 3 = Green, 4 = Blue, 5 = Yellow, 6 = Magenta, 7 = Cyan, 16 = Maroon, 17 = Dark Green, 18 = Dark Blue, 19 = Dark Yellow , a