The Python string object does not have a contains method, and it is not possible to use the String.contains method to determine whether a substring is included, but Python has an easier way to replace the CONTAINS function
The Python string object does not have a contains method, and it is not possible to use the String.contains method to determine whether a substring is included, but Python has an easier way to replace the CONTAINS function
The Python string object does not have a contains method, and it is not possible to use the String.contains method to determine whether a substring is included, but Python has an easier way to replace the CONTAINS function
First, using the in method to achieve the function of contains:
1 ' http://www.baidu.com/ ' 2 if " Baidu " inch A: 3 Print ('A contains ABC')
View Code
Second, using the Find function to realize the function of contains
1 s = " This is a string 2 if s.find (" is Span style= "COLOR: #800000" ">" ) = = -1: 3 print " No ' is ' here! " 4 else : 5 print " found ' is ' in the string. "
View Code
The above 2 ways can be!
Python determines whether a string contains substrings