Python Apache日志处理脚本(初稿)

#!/usr/bin/python
#coding=gb2312
res=[];
linx=[];
f=open('/root/access.log.2');
for line in f.readlines():
    line.rstrip();
    log_home=line.split();
    ip=log_home[0];
    date=log_home[3].replace('[','');
    point=log_home[5].replace('"','');
    path=log_home[6];
    offer=log_home[8];
    linx.append(ip);
    linx.append(date);
    linx.append(point);
    linx.append(path);
    linx.append(offer);
    res.append(linx);
f.close();
print res;

 

posted @ 2013-03-04 15:52  墨迹哥's  阅读(189)  评论(0编辑  收藏  举报