Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > printing escape character

Reply
Thread Tools

printing escape character

 
 
hrochonwo
Guest
Posts: n/a
 
      01-22-2008
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
 
Reply With Quote
 
 
 
 
Jerry Hill
Guest
Posts: n/a
 
      01-22-2008
On Jan 22, 2008 1:38 PM, hrochonwo <> 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
 
Reply With Quote
 
 
 
 
hrochonwo
Guest
Posts: n/a
 
      01-22-2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read strings cantaining escape character from a file and useit as escape sequences? slomo Python 5 12-02-2007 11:39 AM
printing % with printf(), use of \ (escape) character teachtiro@yahoo.com C Programming 7 02-11-2005 10:27 AM
Re: html special character and escape characters knowledgepays@hotmail.com ASP .Net 0 01-27-2005 02:08 AM
RegisterStartupScript / Escape Character George Durzi ASP .Net 0 07-02-2004 07:08 PM
Problem With String Containing JavaScript Escape Character Jeff S ASP .Net 12 11-10-2003 07:19 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57