你可以这样做
import fileinputimport refrom time import strptimef_names = ['1.log', '2.log'] # names of log fileslines = list(fileinput.input(f_names))t_fmt = '%a %b %d %H:%M:%S %Y' # format of time stampst_pat = re.compile(r'[(.+?)]') # pattern to extract timestampfor l in sorted(lines, key=lambda l: strptime(t_pat.search(l).group(1), t_fmt)): print l,
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)