import sys
import urllib
import random
import re
reload(sys)
sys.setdefaultencoding('utf-8')
#正则
r = re.compile(r' elapse (?P<data>[0-9]+)')
#多少分位
marks = [
0,
25,
50,
75,
80,
85,
90,
95
]
datas = []
for m in r.finditer("".join(open(sys.argv[1]).readlines())):
v = m.group('data')
datas.append(float(v.strip()))
datas.sort()
marks.sort()
for mark in marks:
if ((mark > 100) or (mark < 0)):
continue
mark_percent = 1 - float(mark) / 100
mark_size = int(mark_percent * len(datas))
print "%d%% 长尾:\t%f" % (mark, (sum(datas[-mark_size:]) / mark_size))
python统计小脚本
最新推荐文章于 2023-08-15 15:53:47 发布