replacing a substring : Replace « String « Python Tutorial






string1 = "One, one, one, one, one, one"

print "Original:", string1
print 'Replaced "one" with "two":', \
   string1.replace( "one", "two" )
print "Replaced 3 maximum:", string1.replace( "one", "two", 3 )








5.23.Replace
5.23.1.The replace method returns a string where all the occurrences of one string have been replaced by another:
5.23.2.Search and Replace in Strings
5.23.3.replacing a substring