The string module

Various string processing functions

     string.atof(s)             # Convert to float
     string.atoi(s)             # Convert to integer
     string.atol(s)             # Convert to long
     string.count(s,pattern)    # Count occurrences of pattern in s
     string.find(s,pattern)     # Find pattern in s
     string.split(s, sep)       # String a string
     string.join(strlist, sep)  # Join a list of string
     string.replace(s,old,new)  # Replace occurrences of old with new 

Examples

     s = "Hello World"
     a = string.split(s)                 # a = ['Hello','World']
     b = string.replace(s,"Hello","Goodbye")
     c = string.join(["foo","bar"],":")  # c = "foo:bar"
<<< O'Reilly OSCON 2000, Introduction to Python, Slide 122
July 17, 2000, beazley@cs.uchicago.edu
>>>