rstrip() 메서드는 모든 후행 문자(문자열 끝에 있는 문자)를 제거합니다.
공간은 제거할 기본 후행 문자입니다.
매개변수 | 필수 | 설명 |
---|---|---|
characters | 선택 | 후행 문자로 제거할 문자 집합 |
모든 후행 문자(문자열 끝에 있는 문자)를 제거한 결과값을 리턴합니다.
txt = " banana " x = txt.rstrip() print("of all fruits", x, "is my favorite")
결과
of all fruits banana is my favorite
txt = "banana,,,,,ssqqqww....." x = txt.rstrip(",.qsw") print(x)
결과
banana
© 2022 pinfo. All rights reserved.