Python 判断字符串是否包含另一字符串的方法

Spoony 65.05m2021-08-061031 次点击
```
site = '123'
if "12" in site:
print('site contains 12')


s = "This be a string"
if s.find("is") == -1:
print "No 'is' here!"
else:
print "Found 'is' in the string."

contains = 'abcde'.find('bcd') >= 0


contains = 'abcde'.count('bcd') > 0
```
收藏 ♥ 感谢
暂无回复

登录注册 后可回复。



GitHub