我已经看过模块 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。
答案 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