Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a = 1000
- b = 2500
- c = 5213234
- a = 1.000
- b = 2.500
- c = 5.213.234
- '{:,d}'.format(1000)
- # 1,000
- '{:,d}'.format(5213234)
- # 5,213,234
- '{:,d}'.format(2500).replace(',', '.')
- # 2.500
- # pip install humanize
- import humanize
- print(humanize.intcomma(1000)) # '1,000'
- print(humanize.intcomma(2500)) # '2,500'
- print(humanize.intcomma(5213234)) # '5,213,234'
- # Разделители в виде точки лучше не делать, если используются вещественные числа
- c = humanize.intcomma(5213234)
- print(c.replace(',', '.')) # '5.213.234'
- def print_formatted(num):
- print(format(num, ",d").replace(",","."))
- print_formatted(123456898)
Add Comment
Please, Sign In to add comment