#encoding:cp936
from xlwt import *
if __name__==“__main__”:
wb=Workbook()
ws=wb.add_sheet(u”重点网站”)
ws.write(0,0,u”网站”)
ws.write(0,1,u”网址”)
ws.write(0,2,u”存在恶意链接”)
ws.write(0,3,u”恶意链接有效”)
f=open(“malsites.log”,“r”)
i=1
for line in f:
xx=[]
for x in line.split(” “):
if x!=“”:
xx.append(x)
xx[6]=unicode(xx[6],“gb2312”)
ws.write(i,0,xx[6])
ws.write(i,1,xx[0])
i+=1
f.close()
ws1=wb.add_sheet(u”挂马源”)
ws1.write(0,0,u”链接”)
ws1.write(0,1,u”漏洞”)
f=open(“sourses.log”,“r”)
i=1
for line in f:
xx=[]
line=line.split(“n”)[0]
for x in line.split(” “):
if x!=“”:
xx.append(x+“n”)
ws1.write(i,0,xx[3])
i+=1
wb.save(“result.xls”)
转载请注明:爱开源 » python写Excel数据表