파이썬[Python]: 내장함수 - rindex 메서드
파이썬(Python): str 클래스 - rindex 메서드(method)
/// 설명
문자열 중에서 sub 문자열이 발견되어지는 가장 큰 색인(index: 가장 오른쪽에 있는 색인)이 반환됩니다.
start와 end가 주어지면 그 범위 안에서 가장 큰 색인이 반환되고, 실패하면 ValueError 가 발생합니다.
※ 형식
str.rindex(sub)
str.rindex(sub, start)
str.rindex(sub, start, end)
start와 end가 주어지면 그 범위 안에서 가장 큰 색인이 반환되고, 실패하면 ValueError 가 발생합니다.
※ 형식
str.rindex(sub)
str.rindex(sub, start)
str.rindex(sub, start, end)
/// 예제
1 2 3 4 5 6 7 8 9 10 11 | test_str = 'This is a string' # 'This is a string' print(test_str.rindex('i')) # 13 # 'This is a string' print(test_str.rindex('i', 0)) # 13 # 'This is ' print(test_str.rindex('i', 0, 7)) # 5 | cs |
* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)
– 당신을 응원합니다. –
댓글
댓글 쓰기