Advertisement
thefinn93

Untitled

May 18th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. def convert_bytes(bytes):
  2. bytes = float(bytes)
  3. if bytes >= 1099511627776:
  4. terabytes = bytes / 1099511627776
  5. size = '%.2fT' % terabytes
  6. elif bytes >= 1073741824:
  7. gigabytes = bytes / 1073741824
  8. size = '%.2fG' % gigabytes
  9. elif bytes >= 1048576:
  10. megabytes = bytes / 1048576
  11. size = '%.2fM' % megabytes
  12. elif bytes >= 1024:
  13. kilobytes = bytes / 1024
  14. size = '%.2fK' % kilobytes
  15. else:
  16. size = '%.2fb' % bytes
  17. return size
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement