我有一个字符串:
myStr = "Chicago Blackhawks vs. New York Rangers"
我也有一个列表:
myList = ["Toronto Maple Leafs", "New York Rangers"]
使用endswith()方法,我想写一个if语句来检查myString是否以myList中任意一个字符串结尾。我有一个基本的if语句,但我不知道应该在括号里放什么来进行检查。
if myStr.endswith():
print("Success")
if myStr.endswith(tuple(myList)):
- Mazdakword.endswith(('foo', 'bar'))
。 - Lou