I am trying to write an application to convert bytes to kb to mb to gb to tb. Here\'s what I have so far:
def size_format(b): if b < 1000: r
good idea for me:
def convert_bytes(num): """ this function will convert bytes to MB.... GB... etc """ step_unit = 1000.0 #1024 bad the size for x in ['bytes', 'KB', 'MB', 'GB', 'TB']: if num < step_unit: return "%3.1f %s" % (num, x) num /= step_unit