欢迎您 本站地址:  
返回首页   返回编程教学   二刻拍案惊奇  脑筋急转弯  记忆训练翻牌  捕鱼游戏  网页设计书籍  其它模板源码  精选  儿童科普知识 

Python 判断字符串是否存在子字符串

Document 对象参考手册 Python3 实例

给定一个字符串,然后判断指定的子字符串是否存在于该字符串中。

实例

def check(string, sub_str): if (string.find(sub_str) == -1): print("不存在!") else: print("存在!") string = "www.www.fxku.cn" sub_str ="runoob" check(string, sub_str)

执行以上代码输出结果为:

存在!

Document 对象参考手册 Python3 实例

小库提示

扫描下方二维码,访问手机版。