ModdersCentral
Python size to computer size - Printable Version

+- ModdersCentral (http://modderscentral.com)
+-- Forum: Coding (http://modderscentral.com/forumdisplay.php?fid=4)
+--- Forum: Python (http://modderscentral.com/forumdisplay.php?fid=10)
+--- Thread: Python size to computer size (/showthread.php?tid=81)



Python size to computer size - jamie - 11/07/2018

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