Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def convert_bytes(bytes):
- bytes = float(bytes)
- if bytes >= 1099511627776:
- terabytes = bytes / 1099511627776
- size = '%.2fT' % terabytes
- elif bytes >= 1073741824:
- gigabytes = bytes / 1073741824
- size = '%.2fG' % gigabytes
- elif bytes >= 1048576:
- megabytes = bytes / 1048576
- size = '%.2fM' % megabytes
- elif bytes >= 1024:
- kilobytes = bytes / 1024
- size = '%.2fK' % kilobytes
- else:
- size = '%.2fb' % bytes
- return size
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement