Python字符串怎样实现contain

2023-01-31 00:01:47 python 字符串

所属网站分类: Python基础 > 基本数据类型


作者:浮沉

原文链接: Http://www.pythonheidong.com/blog/article/34/

来源:Python黑洞网 www.pythonheidong.com

 

如果你正在寻找Python中的一个类似js的string.contains或string.indexof方法

比喻你想要做如下操作:

 

if not somestring.contains("blah"):
   continue
实际上在python中可以用In实现这个效果:

 

 

if "blah" not in somestring: 
    continue

 




 

相关文章