Python统计PV,UV与访问次数最多的资源

#!/usr/bin/python
#-*- coding: UTF-8 -*-
from collections import Counter

ips = []
c = Counter()
with open('www_access.log') as f:
    for line in f:
        ips.append(line.split()[0])
        c[line.split()[6]] += 1

print("PV is {0}".format(len(ips)))
print("UV is {0}".format(len(set(ips))))
print("Popular resources : {0}".format(c.most_common(10)))


「 文章如果对你有帮助,请点个赞哦^^ 」 

2+