17 lines
379 B
Python
17 lines
379 B
Python
|
from hurry.filesize import size
|
||
|
|
||
|
def filesize(bytes: int, spaces: bool = True):
|
||
|
system = [
|
||
|
(1024 ** 5, ' PB'),
|
||
|
(1024 ** 4, ' TB'),
|
||
|
(1024 ** 3, ' GB'),
|
||
|
(1024 ** 2, ' MB'),
|
||
|
(1024 ** 1, ' KB'),
|
||
|
(1024 ** 0, ' B'),
|
||
|
]
|
||
|
x = size(bytes, system=system)
|
||
|
if spaces:
|
||
|
return x
|
||
|
else:
|
||
|
return x.replace(' ', '')
|