capitalize 메서드
capitalize 메서드는 문자열의 첫 번째 문자를 대문자로,
나머지 모든 문자는 소문자로 변환한 문자열을 반환합니다.
구문
문자열.capitalize()
예제
다음 문자열에 capitalize 메서드를 적용해 보겠습니다:
txt = 'abcde'
print(txt.capitalize())
코드 실행 결과:
'Abcde'
예제
capitalize 메서드와 title 메서드의 적용을 비교해 보겠습니다:
txt = 'abc def'
print(txt.capitalize())
print(txt.title())
코드 실행 결과:
'Abc def'
'Abc Def'