如何使用python读取和处理日志文件

时间:2018-07-18 14:18:16

标签: python automation

对于这里的所有Python Gods,我如何从特定目录中读取多个.log文件(仅包含日志文件),并标记/打印出在Python中重复超过50次的错误/行?我似乎无法弄清楚。

# parselogfiles() uses a line index in every file to search for possible recurrence
def parselogfiles ():
    movefile()
    log_file_path = (moveto + '/*.log')
    files = glob.glob(log_file_path)
    for name in files: # 'file' is a builtin type, 'name' is a less-ambiguous variable name.
        try:
            with open(name) as f:
                sys.stdout.write(f.read())

        except IOError as exc:
            if exc.errno != errno.EISDIR:
                raise ""   

0 个答案:

没有答案
相关问题