영문으로 된 문자열을 소문자로 바꿔야 하는 경우가 있죠, Python 문자열 소문자 변환 방법을 함께 살펴보겠습니다.
목차
Python 문자열 소문자 변환: str.lower() 메서드
우선 대문자 변환에서 str.upper() 메서드를 사용한 것과 같이 소문자 변환에서는 str.lower() 메서드를 사용할 수 있습니다.
string = "I LoVe YoU!"
string.lower()
Python위의 코드를 실행하면 아래 그림과 같이 문자열이 소문자로 변환된 것을 확인할 수 있습니다.

Python 문자열 소문자 변환: str.casefold() 메서드
str.lower() 메서드는 영문에 적용되지만, str.casefold() 메서드는 다국어를 보다 적극적으로 지원합니다. 다음의 독일어 문장은 “나는 축구공을 샀다.”라는 표현입니다.
string = "Ich habe FußBälle gekauft."
>>> string.lower()
>>> string.casefold()
Python아래에서 str.lower() 메서드와 str.casefold() 메서드를 사용한 결과에 차이가 있는 것을 살펴보세요.

재미삼아 대문자를 소문자로 변환해 보기
대문자와 소문자는 ASCII 코드로 일정한 값의 차이가 있습니다. 이를 활용해서 대문자를 소문자로 변환하는 코드를 작성해 보겠습니다.
def lower_case(string):
diff = ord('a') - ord('A')
result = ''
for char in string:
if 'A' <= char <= 'Z':
result += chr(ord(char) + diff)
else:
result += char
return result
print(lower_case("I LoVe YoU!"))
Python위의 코드를 실행해서 아래와 같은 결과를 얻었습니다.

정리
영문만 변환하면 되는 경우에는 str.lower() 메서드를 사용하면 되며, 독일어 등 다국어 표현에서 보다 엄격하게 소문자로 변환하기를 원한다면 str.casefold() 메서드를 사용하면 됩니다.
관련 자료
Python의 Built-in Types를 참고했습니다.