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. Advertising

  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. Advertising

  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. Advertising

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. Kit

    Escape sequences and printing

    Kit, Sep 16, 2003, in forum: C Programming
    Replies:
    5
    Views:
    488
    Matt Gregory
    Sep 17, 2003
  2. Replies:
    7
    Views:
    525
  3. chandanlinster

    printing all escape sequence characters

    chandanlinster, Oct 28, 2006, in forum: C Programming
    Replies:
    5
    Views:
    335
    Kenneth Brody
    Oct 30, 2006
  4. slomo
    Replies:
    5
    Views:
    1,506
    Duncan Booth
    Dec 2, 2007
  5. printing escape characters

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

Share This Page