代码:
str = "Hello,Python"
suffix = "Python"
print(str.endswith(suffix, 2))
输出:
True
分析:
str.endswith(suffix,2) 中的2是指:从字符串"Hello,Python" 中的位置2,也就是第一个‘l’开始检索,判断是否以suffix结尾,故本题输出 True
代码:
str = "Hello,Python"
suffix = "Python"
print(str.endswith(suffix, 2))
输出:
True
分析:
str.endswith(suffix,2) 中的2是指:从字符串"Hello,Python" 中的位置2,也就是第一个‘l’开始检索,判断是否以suffix结尾,故本题输出 True