file / util /file_size.py
Kanhshsh's picture
Upload 60 files
b00d2c6 verified
raw
history blame
293 Bytes
#Thanks @DeletedFromEarth for helping in this journey
def human_size(bytes, units=[' bytes','KB','MB','GB','TB', 'PB', 'EB']):
""" Returns a human readable string representation of bytes """
return str(bytes) + units[0] if int(bytes) < 1024 else human_size(int(bytes)>>10, units[1:])