[TIL] 파이썬에서 숫자에 콤마 찍기

Funnystyle·2021년 4월 3일
0

파이썬에서는 숫자에 콤마 찍는게 되게 쉽네.

>>> total_amount = 10000
>>> print("{:,}".format(total_amount))
10,000

>>> print("Total cost is: ${:,.2f}".format(total_amount))
Total cost is: $10,000.00

참고:
https://stackoverflow.com/questions/5180365/python-add-comma-into-number-string#5180405

profile
polyglot

0개의 댓글