
📌String
- 문자들의 나열
- Immutable
- Ordered
- Iterable
📌String Method
.find(x)
- 문자열 조회/탐색
x의 첫 번째 위치를 반환, 없으면 -1 반환
'water'.find('b')
'useless'.find('s')
.index(x)
x의 첫 번째 위치를 반환, 없으면 오류 발생
'useless'.index('s')
'useless'.index('a')
.replace(old, new[, count])
old를 new로 바꿔서 반환
count를 지정하면 해당 개수만큼 시행
'useless'.replace('s', 'a')
'useless'.replace('s', 'a', 2)
.strip([chars])
- 특정 문자
chars 지정하면, 메소드에 따라 해당 방향에서 제거
- 문자열 지정하지 않으면 공백 제거
.strip() 양쪽, .lstrip() 왼쪽, .rstrip() 오른쪽
' hello '.strip()
' hello '.rstrip()
' hello '.lstrip()
'a b c'.split()
'seperator'.join([iterable])
iterable 컨테이너 요소들을 seperator로 합쳐 문자열 반환
"-".join(['a', 'b', 'c'])
.capitalize() 첫 글자를 대문자, 나머지 소문자
'heLLo'.capitalize()
.title() ' 또는 공백 이후의 첫 문자를 대문자
"heLLo, it's mE".title()
.upper() 모두 대문자
.lower() 모두 소문자
.swapcase() 대문자 <-> 소문자 변경
.isalpha() 알파벳 문자 여부
.isupper() 대문자 여부
.islower() 소문자 여부
.istitle() 타이틀 형식여부
.isdecimal(), .isdigit(), .isnumeric()