10. String operations
Last updated
Last updated
Here's how to replace strings in Python.
Replace substrings: replace()
Specify the maximum count of replacements: count
Replace multiple different substrings
Replace newline character
Replace multiple different characters: translate()
Replace with regular expression: re.sub()
, re.subn()
Replace multiple substrings with the same string
Replace using the matched part
Get the count of replaced parts
Replace by position: slice
因為是iterator的關係,可用