操作文件-取出一个60s内log日志中ip访问次数超过100次的ip

import time
a=0
while True:
d={}
f = open(r"/Users/**juan/Downloads/access.log",encoding="utf-8")
f.seek(a)
for line in f:
if line.split() !="":
f1=line.split(" ")[0]
if f1 not in d:
d[f1]=1
else:
d[f1] += 1
a=f.tell()
print()
for f1 in d:
if d.get(f1) > 100:
print(" %s 出现的次数超过100次"%f1)
time.sleep(60)

猜你喜欢

转载自www.cnblogs.com/wangyajuanjuan/p/11582399.html
今日推荐