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

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

  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. 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. slomo
    Replies:
    5
    Views:
    1,522
    Duncan Booth
    Dec 2, 2007
  2. Alia Khouri
    Replies:
    8
    Views:
    272
    Neil Cerutti
    Apr 5, 2011
  3. Ken Fine
    Replies:
    2
    Views:
    173
    Ken Fine
    Feb 24, 2004
  4. daveyand
    Replies:
    4
    Views:
    452
    Tad McClellan
    May 24, 2006
  5. Nick S
    Replies:
    4
    Views:
    91
    Nick S
    Jun 28, 2008
Loading...

Share This Page