python分析apache和nginx日志文件输出访客ip列表
ips = {} fh = open("/var/log/nginx/access.log", "r").readlines() for line in fh: ip = line.split(" ")[0] if 6 < len(ip) <=15: ips[ip] = ips.get(ip, 0) + 1 print ips
python分析apache和nginx日志文件输出访客ip列表
ips = {} fh = open("/var/log/nginx/access.log", "r").readlines() for line in fh: ip = line.split(" ")[0] if 6 < len(ip) <=15: ips[ip] = ips.get(ip, 0) + 1 print ips