1.格式
endswith(suffix,beg=0,end=len(string))
2、用途:endswith() 方法用于判断字符串是否以指定后缀结尾,如果以指定后缀结尾返回 True,否则返回 False。可选参数 "start" 与 "end" 为检索字符串的开始与结束位置。
3、实例:
str_ewth="my name is zhangsan!!"
print(str_ewth.endswith("!!"))#判断结束字符是否为!!True
print(str_ewth.endswith("nam",3,6))#"nam"是不是从第1个到第6个字符的最后一个字符True
print(str_ewth.endswith("me",4,6))#”m"是从第4个到第5个字符的最后一个。
#True, True, False
| 留言与评论(共有 0 条评论) “” |