📅  最后修改于: 2022-03-11 14:47:17.526000             🧑  作者: Mango
import math
def human_format(number):
units = ['', 'K', 'M', 'G', 'T', 'P']
k = 1000.0
magnitude = int(math.floor(math.log(abs(number), k)))
return f"{number/k**magnitude:.2f}{units[magnitude]}"