下边内容是关于python判断字符串(string)是否包含(contains)子字符串的方法的内容。

 







方法2:使用find函数实现contains的功能

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