file2 / bot /utils /util.py
nothere990's picture
new update
a6fe6f9
raw
history blame contribute delete
315 Bytes
def humanbytes(size):
if not size:
return "0 B"
for unit in ["", "K", "M", "G", "T"]:
if size < 1024:
break
size /= 1024
if isinstance(size, int):
size = f"{size} {unit}B"
elif isinstance(size, float):
size = f"{size:.2f} {unit}B"
return size