반응형 .rjust()1 [Python]숫자, 문자열에 0 또는 다른문자 채우기 .zfill() .rjust() .ljust() .center() Python .zfill() .rjust() .ljust() .center() 모두 문자열 타입 매서드이다. 매서드 풀이 .zfill() 은 지정한 자리수 중, 모자란 자리수에는 0을 채워준다. .zfill(n) format 인자값 : 정수 반환값 : 문자열 print(format(123, '4')) print(format(123, '04')) print(format(123, '10')) print(format(123, '010')) print(type (format(123, '05'))) print('{0:4d}'.format(123)) print('{0:04d}'.format(123)) print('{0:10d}'.format(123)) print('{0:010d}'.format(123)) print.. 2021. 6. 6. 이전 1 다음 반응형