프로그래밍 핵심 개념 in Python자료형문자열을 포매팅하는 다양한 방식

Q

format 매소드 사용법 중에서

조회 207

좋아요 2

2020년 11월 11일




A
3개의 답변이 있어요



2020년 11월 11일

댓글 1

2020년 11월 11일
답글 감사합니다. 하지만 포맷팅할때 %i를 %d 대신에 써도 값은 나올까 해서 해봤는데 똑같이 나오던데요? 그래서 여쭤본거예요ㅜㅜ %i도 십진법을 나타낸다고도 하고요..

참고:
https://stackoverflow.com/questions/17680256/what-is-the-difference-between-i-and-d-in-python

https://codedragon.tistory.com/m/9909



2020년 11월 11일

댓글 1

2020년 11월 11일
답글 감사합니다. 하지만 포맷팅할때 %i를 %d 대신에 써도 값은 나올까 해서 해봤는데 똑같이 나오던데요? 그래서 여쭤본거예요ㅜㅜ %i도 십진법을 나타낸다고도 하고요..(똑같이 정수형이라는 말..)


참고:
https://stackoverflow.com/questions/17680256/what-is-the-difference-between-i-and-d-in-python
https://codedragon.tistory.com/m/9909



2020년 11월 11일

댓글 1

2020년 11월 12일
d Matches an optionally signed decimal integer, whose format is the
same as expected for the subject sequence of the strtol function with
the value 10 for the base argument. The corresponding argument shall
be a pointer to signed integer.

i Matches an optionally signed integer, whose format is the same as
expected for the subject sequence of the strtol function with the
value 0 for the base argument. The corresponding argument shall be a
pointer to signed integer.

찾다보니 이런게 나오긴 하는데 차이점은 %d의 경우 부호가 있는 10진법의 정수를 의미하고 %i의 경우 부호가 있는 정수라고만 표현하네요.

(주) 코드잇

대표강영훈

개인정보보호책임자강영훈

이메일support@codeit.kr

사업자 번호313-86-00797

통신판매업제 2019-서울중구-1034 호

주소서울특별시 중구 청계천로 100 시그니쳐타워 동관 10층 코드잇