[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

printing escape character

hrochonwo

1/22/2008 6:38:00 PM

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 ?


thanks for any reply

hrocho
2 Answers

Jerry Hill

1/22/2008 6:59:00 PM

0

On Jan 22, 2008 1:38 PM, hrochonwo <hrochonwo@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

hrochonwo

1/22/2008 7:04:00 PM

0

On Jan 22, 7:58 pm, "Jerry Hill" <malaclyp...@gmail.com> wrote:
> On Jan 22, 2008 1:38 PM, hrochonwo <hrocho...@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


thank you, jerry