파이썬 문자열 rstrip() 메서드
예시
문자열 끝에 있는 공백을 제거합니다.
txt = " banana "
x =
txt.rstrip()
print("of all fruits", x, "is my favorite")
정의 및 사용
이 rstrip()
메서드는 후행 문자(문자열 끝에 있는 문자)를 제거하고 공백은 제거할 기본 후행 문자입니다.
통사론
string.rstrip(characters)
매개변수 값
Parameter | Description |
---|---|
characters | Optional. A set of characters to remove as trailing characters |
더 많은 예
예시
쉼표, s, q 또는 w인 경우 후행 문자를 제거합니다.
txt = "banana,,,,,ssqqqww....."
x = txt.rstrip(",.qsw")
print(x)