Have to try
Jason Orendorff
jason at jorendorff.com
Sat Feb 16 23:07:31 EST 2002
Rick Hamilton writes:
> I want to search that string for the occurrence of a sub string.
> I have tried
> Find(s,sub)
> Rfind
> MyString.find(sub)
It looks like you're using an extra-old version of Python,
because mystring.find(sub) really should work.
http://www.python.org/doc/current/lib/string-methods.html
>>> x = "lovely spam, wonderful spam!"
>>> x.find('spam')
7
>>> x.find('food')
-1
So you must be using Python 1.6 or earlier. Try this.
http://www.python.org/doc/current/lib/module-string.html
>>> import string
>>> string.find(x, 'spam')
7
## Jason Orendorff http://www.jorendorff.com/
More information about the Python-list
mailing list