파이썬 문자열 endwith() 메서드
예시
문자열이 구두점 기호(.)로 끝나는지 확인합니다.
txt = "Hello, welcome to my world."
x = txt.endswith(".")
print(x)
정의 및 사용
이 endswith()
메서드는 문자열이 지정된 값으로 끝나면 True를 반환하고 그렇지 않으면 False를 반환합니다.
통사론
string.endswith(value, start, end)
매개변수 값
Parameter | Description |
---|---|
value | Required. The value to check if the string ends with |
start | Optional. An Integer specifying at which position to start the search |
end | Optional. An Integer specifying at which position to end the search |
더 많은 예
예시
문자열이 "my world."라는 문구로 끝나는지 확인합니다.
txt = "Hello, welcome to my world."
x = txt.endswith("my world.")
print(x)
예시
위치 5에서 11이 "my world"로 끝나는지 확인합니다.
txt = "Hello, welcome to my world."
x = txt.endswith("my world.",
5, 11)
print(x)