17 lines
423 B
Python
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))
|