함수 endsWith()

1 Python[ | ]

print('world'.endswith('world'));         # True
print('hello world'.endswith('world'));   # True
print( 'hello worl'.endswith('hello') );  # False
# handmade for fun
import re
def my_endswith(needle, haystack):
    return not not re.match(r'.*'+needle+'$', haystack)

print(my_endswith('world', 'world'));       # True
print(my_endswith('world', 'hello world')); # True
print(my_endswith('world', 'hello worl'));  # False

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}