Escape curly bracket together to a variable extension

Discussion in 'Python' started by Joan Miller, Mar 6, 2010.

  1. Joan Miller

    Joan Miller Guest

    How to escape the first '}' in the next string?

    s = "}\n{0}".format('foo')
     
    Joan Miller, Mar 6, 2010
    #1
    1. Advertisements

  2. * Joan Miller:
    > How to escape the first '}' in the next string?
    >
    > s = "}\n{0}".format('foo')


    s = "}}\n{0}".format('foo')


    Cheers & hth.,

    - Alf
     
    Alf P. Steinbach, Mar 6, 2010
    #2
    1. Advertisements

  3. Joan Miller

    Gary Herron Guest

    Joan Miller wrote:
    > How to escape the first '}' in the next string?
    >
    > s = "}\n{0}".format('foo')
    >
    >>> "}}\n{0}".format('foo')

    '}\nfoo'


    Gary Herron
     
    Gary Herron, Mar 6, 2010
    #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. Dustin D.
    Replies:
    0
    Views:
    2,592
    Dustin D.
    Aug 27, 2003
  2. Geathaa
    Replies:
    1
    Views:
    655
    Martin Honnen
    Sep 12, 2003
  3. inquirydog

    call-template in curly brackets

    inquirydog, Dec 13, 2003, in forum: XML
    Replies:
    1
    Views:
    721
    Julian Reschke
    Dec 13, 2003
  4. slomo
    Replies:
    5
    Views:
    2,135
    Duncan Booth
    Dec 2, 2007
  5. Alia Khouri
    Replies:
    8
    Views:
    449
    Neil Cerutti
    Apr 5, 2011
  6. Ken Fine
    Replies:
    2
    Views:
    282
    Ken Fine
    Feb 24, 2004
  7. daveyand
    Replies:
    4
    Views:
    667
    Tad McClellan
    May 24, 2006
  8. Nick S
    Replies:
    4
    Views:
    155
    Nick S
    Jun 28, 2008
Loading...