码迷,mamicode.com
首页 > 编程语言 > 详细

Python 统计IIS日志行数

时间:2014-10-30 10:54:09      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   for   sp   div   on   log   ad   

__author__ = Administrator
import codecs

def blocks(file, size=65536):
    while True:
        b = file.read(size)
        if not b: break
        yield b

with  codecs. open(h:/iis/u_ex141026.log, r,gbk, ignore) as f:
     print( sum(bl.count("\n") for bl in blocks(f)))

 

Python真短啊

Python 统计IIS日志行数

标签:style   blog   color   for   sp   div   on   log   ad   

原文地址:http://www.cnblogs.com/zbw911/p/4062018.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!