This article describes how to find a specified string in python by referring to the following method:
Code
# Query def selStr (): sStr1 = 'jsjtt. com 'sstr2 = 'com' # index to query a string, returns the index nPos = sStr1.index (sStr2) if (nPos> = 0 ): print 'sstr1 contains the character 'print nPos # find 'in sStr2. if the find method is not found,-1 nPos2 = sStr1.find ('ABC') is returned ') print nPos2 # the position where the returned characters are located. print sStr1.find ('com ') selStr ();
Python delimiter
Def split (): sStr1 = 'AB, cde, fgh, ijk 'sstr2 =', '# Use find to find the index location where the comma is located sStr1 = sStr1 [sStr1.find (sStr2) + 1:] print sStr1 # use the split function to split the string s = 'AB, cde, fgh, ijk' result = s. split (',') print (result [0]) split ();
Thank you for reading this article. I hope it will help you. thank you for your support for this site!
For more details about how to find a string in python, refer to PHP!