Answers for "python long numbers as string"

0

python long numbers as string

import math

def human_format(number):
    units = ['', 'K', 'M', 'G', 'T', 'P']
    k = 1000.0
    magnitude = int(math.floor(math.log(abs(number), k)))
    return f"{number/k**magnitude:.2f}{units[magnitude]}"
Posted by: Guest on August-02-2021

Python Answers by Framework

Browse Popular Code Answers by Language