首页 > 代码库 > Python 统计IIS日志行数

Python 统计IIS日志行数

__author__ = Administratorimport codecsdef blocks(file, size=65536):    while True:        b = file.read(size)        if not b: break        yield bwith  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日志行数