def convertSize(size):
if (size == 0):
return '0 Bytes'
size_name = ("Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
i = int(math.floor(math.log(size,1024)))
p = math.pow(1024,i)
s = round(size/p,2)
return '{} {}'.format(s,size_name[i])
评论列表
文章目录