For details about whether an instance exists in the python query string, refer to the python instance.
The following describes how to search for a specified string in python:
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!