S
S
Sergey Nizhny Novgorod2016-03-08 15:11:10
Python
Sergey Nizhny Novgorod, 2016-03-08 15:11:10

How to remove escape characters in Python?

Guys, tell me please.
Got a line with escape characters /n etc. Is there any method how to remove this case, or only through a loop with conditions? Sorry for the stupid question, I can't find anything in the manual.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
W
warnerbrowsers, 2016-03-08
@warnerbrowsers

Maybe the replace method will help? Replace "\n" with ""

V
Vladimir Kuts, 2016-03-09
@fox_12

your_str.replace('\n','')

A
Alexander Titov, 2016-03-09
@alex-t

Is that what was meant?

>>> import re
>>> ss = 'aaa\\nbbb\\tccc'
>>> re.sub('\\\\.', ss, '\\$')
'aaa\nbbb\tccc'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question