ModdersCentral

Full Version: Python size to computer size
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
def convert_bytes(num): 
    for x in ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB','EB','YB']:
        if num < 1024.0:
            return  str(round(num,2)) + ' ' + x 
        num /= 1024.0
usage:
Code:
print(convert_bytes(1024000 * 2))
www.000webhost.com