본문 바로가기
Programming Language/Python

[Python] 1_000은 도대체 뭘까

by veggie-garden 2022. 6. 14.

백준을 풀면서 다른 사람들 코드를 보는 중 i = 1_000 또는 i = 1_000_000 같은 코드를 봤다. 

 

바로 스택오버플로우에 찾아봤다. https://stackoverflow.com/questions/49837534/what-do-1-000-and-100-000-mean

 

What do 1_000 and 100_000 mean?

Since I've been learning Python, I've sometimes seen beginner examples that look like this: sum_sq = [None] * 1_000 I've bought three Python books and none have mentioned what the 1_000 and 100_000

stackoverflow.com

 

답변에 따르자면 무슨 큰 의미는 없고, 그저 숫자를 읽기 편하게 표기하는 법이라고 하였다.

 

공식 문서에도 적혀있다. 

The underscores have no semantic meaning, and literals are parsed as if the underscores were absent.

 

호오... 이런 것도 다 있구나. 역시 별의 별게 다 있는 파이썬.  

댓글