티스토리 뷰
대소문자 변환하는 String 메서드에 대해 알아보도록 하겠습니다.
아래 작성한 예제를 통해 확인할 수 있습니다.
a = 'Hello world'
print("소문자: " + a.lower())
# 결과: hello world
print("대문자: " + a.upper())
# 결과: HELLO WORLD
print("대소문자: " + a.swapcase())
# 결과: hELLO WORLD
b = 'cat dog'
print("첫글자만 대문자: " + b.capitalize())
# 결과: Cat dog
print("각단어의 첫글자만 대문자: " + b.title())
# 결과: Cat Dog
대소문자 변환하는 메서드에 대해 알아보았습니다.
끝.
728x90
'Python' 카테고리의 다른 글
[Python] if (0) | 2022.09.02 |
---|---|
[Python] String Method (0) | 2022.08.25 |
[Python] index (0) | 2022.08.12 |
[Python] bool() (0) | 2022.08.10 |
[Python] 연산자 Operators (0) | 2022.08.09 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- index
- find
- Built-in Functions
- Python
- Method
- for
- Lower
- isalpha
- function
- counter
- zip
- combinations
- bool
- Lambda
- If
- Upper
- isdigit
- operators
- permutations
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
글 보관함