python匹配相关网站日志


#coding: utf-8
02
import re, time
03
 
04
def calTime(func):
05
    def wrapper():
06
        start = time.time()
07
        func()
08
        end = time.time()
09
        print end - start
10
    return wrapper
11
 
12
@calTime
13
def sumAll():
14
    pattern = re.compile(u'/home/shopping/public_html/(.*)', re.I | re.S)
15
    f = open('new_log.txt', 'w')
16
    repeat = [];
17
    for line in open('error_log.log'):
18
            match = pattern.search(line)
19
            if match:
20
                repeat.append(match.group(0))
21
    no_repeat = set(repeat)
22
    for line in no_repeat:
23
        f.write(line)
24
 
25
sumAll()

相关内容

    暂无相关文章

评论关闭