[Python] Converting, Replacing, and Removing Line Breaks with string.replace()
I’ll introduce methods to convert, replace, and remove line breaks in Python.
You can use string.replace() to appropriately replace line break codes contained in strings.
If you want to remove line breaks, you can replace them with an empty string ” as follows.
>>> text = 'こんにちは。\\r\nありがとう!'
>>> print text
こんにちは。
ありがとう!
>>> text = text.replace('\\r\n','')
>>> print text
こんにちは。ありがとう!
That’s all from the Gemba.