Skip to content

Instantly share code, notes, and snippets.

@deleted
Created April 15, 2010 22:42
Show Gist options
  • Save deleted/367763 to your computer and use it in GitHub Desktop.
Save deleted/367763 to your computer and use it in GitHub Desktop.
def sizeof_human(numbytes):
''' Human-readable size strings '''
assert numbytes >= 0
for x in ['bytes','KB','MB','GB','TB','PB']:
if numbytes < 1024.0:
return "%3.2f%s" % (numbytes, x)
numbytes /= 1024.0
else:
return "Exabytes!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment