判断字符串是否以某个串为结尾:

str.endswith(strtmp)  返回True/False

1 >>> strs='aba'
2 >>> strs.endswith('ba')
3 True
4 >>> strs.endswith('b')
5 False

 

检查某字符串是否为另一字符串的子串:

str.find(strtmp)方法  返回首次出现的下标位置,不存在则返回-1

1 >>> strs='aba'
2 >>> strs.find('b')
3 1
4 >>> strs.find('a')
5 0
6 >>> strs.find('c')
7 -1

in使用  strtmp in str  返回True/False

1 >>> strs='aba'
2 >>> 'b' in strs
3 True
4 >>> 'a' in strs
5 True
6 >>> 'c' in strs
7 False