Daily Shaarli

All links of one day in a single page.

10/17/23

Replace strings in Python (replace, translate, re.sub, re.subn) | note.nkmk.me

In Python, you can replace strings using the replace() and translate() methods, or the regular expression functions, re.sub() and re.subn(). You can also replace substrings at specified positions using slicing.Replace substrings in a string: replace()Basic usageSpecify the maximum count of replaceme...