formatting number of bytes to human readable format
Rob Weir
rweir at ertius.org
Tue Aug 12 22:31:50 EDT 2008
On 13 Aug 2008, rkmr wrote:
> is there any library / function that prints number of bytes in human
> readable format?
> for example
>
> a=XX(1048576)
> print a
>
> should output
> 1 MB
http://mail.python.org/pipermail/python-list/1999-December/018519.html
is a good start - just need to change the table to something like::
_abbrevs = [
(2 ** 30L - 1, 'G'),
(2 ** 20L - 1, 'M'),
(2 ** 10L - 1, 'K'),
(1, '')
]
(and add a 'B').
--
-rob
More information about the Python-list
mailing list