Python의 문자열 대문자
Muhammad Maisam Abbas
2023년10월10일
Python
Python String

이 튜토리얼에서는 파이썬에서 문자열 대문자 화에 사용되는 방법에 대해 설명합니다.
Python에서upper()
함수를 사용한 문자열 대문자 화
upper()
함수는 모두 대문자로 된 문자열을 제공합니다. 다음 코드 예제는upper()
함수를 사용하여 Python에서 문자열을 대문자로 표시하는 방법을 보여줍니다.
string = "this is a string."
uppercasestring = string.upper()
print(uppercasestring)
출력:
THIS IS A STRING
위의 코드에서 먼저 모든 소문자로 문자열을 초기화합니다. 그 후upper()
함수를 사용하여 문자열을 대문자로 변환합니다.
upper()
는 모든 문자를 대문자로 변환합니다. 문자열의 첫 번째 문자 만 대문자로 바꾸려면capitalize()
함수를 사용해야합니다.
Python에서capitalize()
함수를 사용한 문자열 대문자 화
capitalize()
함수는 문자열의 첫 글자 만 대문자로 변환합니다. 다음 코드 예제는capitalize()
함수를 사용하여 문자열을 대문자로 표시하는 방법을 보여줍니다.
string = "this is a string."
capitalizedstring = string.capitalize()
print(capitalizedstring)
출력:
This is a string.
위의 코드에서 먼저 모든 소문자로 문자열을 초기화합니다. 그 후capitalize()
함수를 사용하여 문자열의 첫 번째 문자를 대문자로 표시합니다.
튜토리얼이 마음에 드시나요? DelftStack을 구독하세요 YouTube에서 저희가 더 많은 고품질 비디오 가이드를 제작할 수 있도록 지원해주세요. 구독하다
Maisam is a highly skilled and motivated Data Scientist. He has over 4 years of experience with Python programming language. He loves solving complex problems and sharing his results on the internet.
LinkedIn