printing escape character

Jerry Hill malaclypse2 at gmail.com
Tue Jan 22 13:58:50 EST 2008


On Jan 22, 2008 1:38 PM, hrochonwo <hrochonwo at googlemail.com> wrote:
> Hi,
>
> I want to print string without "decoding" escaped characters to
> newline etc.
> like print "a\nb" -> a\nb
> is there a simple way to do it in python or should i somehow use
> string.replace(..) function ?

>>> print 'a\nb'.encode('string_escape')
a\nb

-- 
Jerry



More information about the Python-list mailing list