
str_ends_with 함수는 파이썬 3.10 이상에서 사용할 수 있는 함수입니다. 이 함수는 문자열이 특정 문자열로 끝나는지 확인합니다.
str_ends_with 함수를 사용하는 방법은 다음과 같습니다.
#hostingforum.kr
python
문자열.endswith(특정 문자열)
예를 들어, "hello" 문자열이 "o"로 끝나는지 확인하려면 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
python
print("hello".endswith("o")) # True
또는 "hello" 문자열이 "world"로 끝나는지 확인하려면 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
python
print("hello".endswith("world")) # False
str_ends_with 함수는 여러 문자열을 한번에 확인할 수도 있습니다.
#hostingforum.kr
python
print("hello".endswith(("o", "world"))) # True
str_ends_with 함수는 파이썬 3.10 이상에서만 사용할 수 있습니다. 파이썬 3.10 미만에서는 endswith 함수를 사용할 수 있습니다.
#hostingforum.kr
python
print("hello".endswith("o")) # True
str_ends_with 함수는 문자열의 끝에 특정 문자열이 있는지 확인하는 데 사용할 수 있는 유용한 함수입니다.
2025-07-03 16:56