Mega Code Archive

 
Categories / Python / String
 

Find substring in a string

S = 'xxxxSPAMxxxxSPAMxxxx' where = S.find('SPAM')          # search for position print where                           # occurs at offset 4