path

Erik Max Francis max at alcyone.com
Sat Oct 22 23:17:00 EDT 2005


Shi Mu wrote:

> what is the differenc ebetween index and find in the module of string?
> for both "find" and "index", I got the position of the letter.

 >>> import string
 >>> help(string.find)
Help on function find in module string:

find(s, *args)
     find(s, sub [,start [,end]]) -> in

     Return the lowest index in s where substring sub is found,
     such that sub is contained within s[start,end].  Optional
     arguments start and end are interpreted as in slice notation.

     Return -1 on failure.

 >>> help(string.index)
Help on function index in module string:

index(s, *args)
     index(s, sub [,start [,end]]) -> int

     Like find but raises ValueError when the substring is not found.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   I can't remember to forget you.
   -- Leonard Shelby



More information about the Python-list mailing list