Data house
[python] 공백 제거 & 문자열 앞 또는 뒤 특정 문자 제거 본문
728x90
공백 제거
- trim(): 양쪽 공백 제거
- lstrim(): 왼쪽 공백 제거
- rstrim(): 오른쪽 공백 제거
특정 문자 제거
- strip('4'): 문자열 앞 뒤쪽에 4를 제거함
- lstrip('3'): 문자열 앞쪽 3을 제거함
- rstrip('2'): 문자열 뒤쪽 2를 제거함
'Computer Knowledge > 코테 대비 오답노트' 카테고리의 다른 글
[python] 4개 숫자들 중 중복된 숫자마다 처리 - count(), index() (0) | 2023.05.14 |
---|---|
[python] 접두사, 접미사인지 알아보기 - startwith, endwith (0) | 2023.05.12 |
[python] str.replace() (0) | 2023.05.08 |
python 부분 문자열 (0) | 2023.05.08 |
[어이털리는 알고리즘] python/string - raw string, join (1) | 2023.05.06 |