Python 3 教程教程
Python 判断字符串是否存在子字符串
Python 判断字符串是否存在子字符串
Python 判断字符串是否存在子字符串
Python3 实例给定一个字符串,然后判断指定的子字符串是否存在于改字符串中。
实例
def check(string, sub_str):
if (string.find(sub_str) == -1):
print("不存在!")
else:
print("存在!")
string = "www.verydoc.net"
sub_str ="verydoc"
check(string, sub_str)
执行以上代码输出结果为:
存在!Python3 实例
Python 判断字符串是否存在子字符串 |
---|
Python 3 教程
Python的3.0版本,常被称为Python 3000,或简称Py3k。相对于Python的早期版本,这是一个较大的升级。为了不带入过多的累赘,Python 3.0在设计的时候没有考虑向下兼容。