Python remove line breaks -
this question has answer here:
- remove line breaks long string of text 5 answers
i'm reading output program this
test_output = test_run.communicate(input=str.encode(input))[0] output = test_output .decode('utf-8').strip() and if program returns new line this
>>> >>> b it reads this(with repr())
>>> 'a\r\nb' i tried removing line breaks
output.replace(r"\r\n","") but it's not working, if print regular string returns
>>> >>> b and repr()
>>> 'a\r\nb' how can remove \r\n string?
don't use regexp, regexp doesn't think does:
>>> 'a\r\nb'.replace('\r\n', '') 'ab' i.e. remove r in replace(r'\r\n', '')
Comments
Post a Comment