sed to python: replace Q

happyriding happyriding at yahoo.com
Wed Apr 30 02:59:53 EDT 2008


On Apr 29, 11:27 pm, Raymond <not-for-m... at sonic.net> wrote:
> For some reason I'm unable to grok Python's string.replace() function.

line = "abc"
line = line.replace("a", "x")
print line

--output:--
xbc

line = "abc"
line = line.replace("[apq]", "x")
print line

--output:--
abc


Does the 5 character substring "[apq]" exist anywhere in the original
string?



More information about the Python-list mailing list