Convertir les blocs en MB Python

# Input 
#   size - in blocks
# Output
#   size - to the nearest possible unit with 1 decimal precision
#   power label - to indicate if its rounded to Blocks, KB, MB, GB or TB
def format_bytes(size):
    # 2**10 = 1024
    power = 2**10
    n = 0
    power_labels = {0 : 'Blocks', 1: 'KB', 2: 'MB', 3: 'GB', 4: 'TB'}
    while size > power:
        size /= power
        n += 1
    return size, power_labels[n]
Tense Tarantula