Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def human_format(num):
- num = int(num)
- if num < 1000:
- return num
- magnitude = 0
- while abs(num) >= 1000:
- magnitude += 1
- num /= 1000.0
- # thousands, millions, billions, trillions, quadrillion
- return '%.2f%s' % (num, ['', 'K', 'M', 'B', 'T', 'Qd', 'Qt', 'S', 'Qd', 'Qt', 'S', 'Oc', 'Non', 'Dec'][magnitude])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement