人类可读输出的位

时间:2016-09-09 18:45:05

标签: python

我已经看过模块 humanize humanfriendly ,并且都不能将大比特值转换为人类可读比特输出(例如Mbits,Gbits,Tbits,..等等)。有人遇到过这样的模块吗?例如:

mbits = 1000000
gbits = 1000000000

然后

print(human.bits(mbits)) # would output "1 Mbit"
print(human.bits(gbits)) # would output "1 Gbit"

......等等,直到exabit。

1 个答案:

答案 0 :(得分:0)

您可以尝试hurry.filesize

>>> from hurry.filesize import size
>>> size(11000)
'10K'

还有另一个图书馆bitmath

>>> from bitmath import *
>>> small_number = MiB(10000)
>>> print small_number.best_prefix()
9.765625 GiB