Your original string, a = 'a\\nb'
does not actually have two '\'
characters, the first one is an escape for the latter. If you do, print a
, you'll see that you actually have only one '\'
character.
>>> a = 'a\\nb'
>>> print a
a\nb
If, however, what you mean is to interpret the '\n'
as a newline character, without escaping the slash, then:
>>> b = a.replace('\\n', '\n')
>>> b
'a\nb'
>>> print b
a
b