format( )으로 숫자에 콤마 넣기
num = 12300000
print(format(num, ','))
12,300,000
문자열 format으로 숫자에 콤마 넣기
num = 12300000
print('{0:,}'.format(num))
num = 12300000.111
print('{0:,}'.format(num))
12,300,000
12,300,000.111
f-string으로 숫자에 콤마 넣기
num = 12300000
print(f'{num:,}')
num = 12300000.111
print(f'{num:,}')
12,300,000
12,300,000.111
'Python > Python 문법 기초' 카테고리의 다른 글
Python - Zipfile (0) | 2024.04.18 |
---|---|
Python 함수 - 기초 예제 (0) | 2024.04.05 |
Python 함수 - 기초 (0) | 2024.04.04 |
반복문 - 기초 예제 (0) | 2024.04.04 |
조건문 - 기초 (0) | 2024.04.04 |