CS2613/labs/L14/client.py
2022-10-31 09:58:30 -03:00

17 lines
423 B
Python

import humansize
def approximate_size(size):
"""Returns the size of a file in a human-readable format where kilobytes are 1000 bytes
:param size: the size of a file
:return: string
"""
return humansize.approximate_size(size, False)
if __name__ == '__main__': # pragma: no cover
print(approximate_size(1_000))
print(approximate_size(100_000_000))
print(approximate_size(1_000_000_000))