Search notes:

Python: str.replace()

str.replace(old, new) replaces the text sequence old with new in str.
#!/usr/bin/python3

txt = 'Foo bar baz'

print(txt.replace('o' , 'u' )) # Fuu bar baz
print(txt.replace('a' , 'AA')) # Foo bAAr bAAz
print(txt.replace('ar', 'XY')) # Foo bXY baz
Github repository about-python, path: /built-in/types/str/replace.py

See also

str.translate()
str

Index