python判断字符串是否包含子字符串
python的string对象没有contains方法,不可以使用string.contains的方法判断是否包含子字符串,但是python有更简单的方法来替换contains函数
python的string对象没有contains方法,不可以使用string.contains的方法判断是否包含子字符串,但是python有更简单的方法来替换contains函数
python的string对象没有contains方法,不可以使用string.contains的方法判断是否包含子字符串,但是python有更简单的方法来替换contains函数
一、使用 in 方法实现contains的功能:
1 a = 'http://www.baidu.com/' 2 if "baidu" in a: 3 print('a contains abc')
二、使用find函数实现contains的功能
1 s = "This be a string" 2 if s.find("is") == -1: 3 print "No 'is' here!" 4 else: 5 print "Found 'is' in the string."
以上2种方法都可以!
毕业后这5年里的迷茫,会造成10年后的恐慌,20年后的挣扎,甚至一辈子的平庸!。
人生的道路犹如自己的内裤,没有一条不是自己选的!

浙公网安备 33010602011771号