标签:rate 代码 sed ref 字节 div turn value pytho
def bytes2human(n):
symbols = (‘K‘, ‘M‘, ‘G‘, ‘T‘, ‘P‘, ‘E‘, ‘Z‘, ‘Y‘)
prefix = {}
for i, s in enumerate(symbols):
prefix[s] = 1 << (i + 1) * 10
for s in reversed(symbols):
if n >= prefix[s]:
value = float(n) / prefix[s]
return ‘%.1f%s‘ % (value,s)
return ‘%sB‘ % n
标签:rate 代码 sed ref 字节 div turn value pytho
原文地址:https://www.cnblogs.com/superniao/p/10554351.html