printing escape character

Discussion in 'Python' started by hrochonwo, Jan 22, 2008.

  1. hrochonwo

    hrochonwo Guest

    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
     
    hrochonwo, Jan 22, 2008
    #1
    1. Advertisements

  2. hrochonwo

    Jerry Hill Guest

    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
     
    Jerry Hill, Jan 22, 2008
    #2
    1. Advertisements

  3. hrochonwo

    hrochonwo Guest

    On Jan 22, 7:58 pm, "Jerry Hill" <> wrote:
    > 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



    thank you, jerry
     
    hrochonwo, Jan 22, 2008
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff S
    Replies:
    12
    Views:
    14,180
    Jeff S
    Nov 10, 2003
  2. George Durzi

    RegisterStartupScript / Escape Character

    George Durzi, Jul 2, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    771
    George Durzi
    Jul 2, 2004
  3. =?Utf-8?B?Q29vbEtpd2lCbG9rZQ==?=

    URL Escape Character Problem (Bug in ASP.NET??)

    =?Utf-8?B?Q29vbEtpd2lCbG9rZQ==?=, Mar 8, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    4,895
    Joerg Jooss
    Mar 10, 2005
  4. Kit

    Escape sequences and printing

    Kit, Sep 16, 2003, in forum: C Programming
    Replies:
    5
    Views:
    754
    Matt Gregory
    Sep 17, 2003
  5. Replies:
    7
    Views:
    675
  6. chandanlinster

    printing all escape sequence characters

    chandanlinster, Oct 28, 2006, in forum: C Programming
    Replies:
    5
    Views:
    439
    Kenneth Brody
    Oct 30, 2006
  7. slomo
    Replies:
    5
    Views:
    2,112
    Duncan Booth
    Dec 2, 2007
  8. printing escape characters

    , Nov 10, 2005, in forum: Perl Misc
    Replies:
    5
    Views:
    144
    John Bokma
    Nov 11, 2005
Loading...