[python] 문자열 대소문자 변환
Python에서 문자열을 대문자로 바꾸거나 소문자로 바꾸는 것은 매우 간단합니다. 내장된 upper()
와 lower()
메서드를 사용하여 간단히 문자열을 변경할 수 있습니다.
소문자로 변환하기
text = "Hello, World!"
lower_text = text.lower()
print(lower_text)
이 코드는 “hello, world!”를 출력합니다.
대문자로 변환하기
text = "Hello, World!"
upper_text = text.upper()
print(upper_text)
이 코드는 “HELLO, WORLD!”를 출력합니다.
참고 자료
Python 공식 문서: 문자열 메서드