대문자인지 소문자인지 반환, 그리고 대문자 혹은 소문자로 만들기

Python

1 분 읽기

isupper, islower : 대문자인지 소문자인지

메서드 설명
str.isupper() 스트링이 모두 대문자인지 여부 반환
str.islower() 스트링이 모두 소문자인지 여부 반환
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
text1 = "Hello World"
text2 = "UPPER"
text3 = "lower"

# isupper
print(text1.isupper())
# >>> False
print(text2.isupper())
# >>> True
print(text3.isupper())
# >>> False

# islower
print(text1.islower())
# >>> False
print(text2.islower())
# >>> False
print(text3.islower())
# >>> True

upper, lower : 대문자 혹은 소문자로 변환

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
text1 = "Hello World"
text2 = "UPPER"
text3 = "lower"

print(text1.upper())
# >>> HELLO WORLD
print(text2.upper())
# >>> UPPER
print(text3.upper())
# >>> LOWER

print(text1.lower())
# >>> hello world
print(text2.lower())
# >>> upper
print(text3.lower())
# >>> lower

// reading compass

이 글과 이어지는 경로

시리즈, 카테고리, 태그 겹침, 최신도를 점수화해 가까운 글일수록 중심에 배치합니다.

hover nodes or cards · click a node to pin
Next reads 0

    댓글 남기기