python - Python 是否有字符串 'contains' 子字符串方法?

我正在寻找 Python 中的 string.containsstring.indexof 方法。

我想做:

if not somestring.contains("blah"):
   continue

最佳答案

使用 in operator :

if "blah" not in somestring: 
    continue

关于python - Python 是否有字符串 'contains' 子字符串方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3437059/

相关文章:

python - 如何检查列表是否为空?

python - 如何按值对字典进行排序?

python - 使用 'for' 循环遍历字典

python - 查找列表中项目的索引

python - @staticmethod 和 @classmethod 之间的区别

python - 在 'for' 循环中访问索引

python - 了解切片

python - 如何列出目录的所有文件?

python - 在函数中使用全局变量

python - Python 的列表方法 append 和 extend 有什么区别?