Guest User

Untitled

a guest
Jul 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. a = 1000
  2. b = 2500
  3. c = 5213234
  4.  
  5. a = 1.000
  6. b = 2.500
  7. c = 5.213.234
  8.  
  9. '{:,d}'.format(1000)
  10. # 1,000
  11.  
  12. '{:,d}'.format(5213234)
  13. # 5,213,234
  14.  
  15. '{:,d}'.format(2500).replace(',', '.')
  16. # 2.500
  17.  
  18. # pip install humanize
  19. import humanize
  20.  
  21. print(humanize.intcomma(1000)) # '1,000'
  22. print(humanize.intcomma(2500)) # '2,500'
  23. print(humanize.intcomma(5213234)) # '5,213,234'
  24.  
  25. # Разделители в виде точки лучше не делать, если используются вещественные числа
  26. c = humanize.intcomma(5213234)
  27. print(c.replace(',', '.')) # '5.213.234'
  28.  
  29. def print_formatted(num):
  30. print(format(num, ",d").replace(",","."))
  31.  
  32. print_formatted(123456898)
Add Comment
Please, Sign In to add comment