Logo

Programming-Idioms

History of Idiom 63 > diff from v18 to v19

Edit summary for version 19 by :

Version 18

2015-10-29, 14:05:15

Version 19

2015-10-31, 15:01:09

Idiom #63 Replace fragment of a string

Assign to x2 the value of string x with all occurrences of y replaced by z.
Assume occurrences of y are not overlapping.

Idiom #63 Replace fragment of a string

Assign to x2 the value of string x with all occurrences of y replaced by z.
Assume occurrences of y are not overlapping.

Code
x2 = x.replace(y, z)
Doc URL
https://docs.python.org/3/library/stdtypes.html#str.replace