我认为没有内置功能可以做到这一点。您必须自己滚动,例如:
def human_format(num): magnitude = 0 while abs(num) >= 1000: magnitude += 1 num /= 1000.0 # add more suffixes if you need them return '%.2f%s' % (num, ['', 'K', 'M', 'G', 'T', 'P'][magnitude])print('the answer is %s' % human_format(7436313)) # prints 'the answer is 7.44M'
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)