Can you escape a % in string that will used for substitution

Discussion in 'Python' started by Gerard Brunick, Oct 18, 2007.

  1. Is there a way to do:

    s = "I like python %i%s of the time."
    print s % (99, "%")

    without having to pass in "%"?

    Thanks,
    Gerard
     
    Gerard Brunick, Oct 18, 2007
    #1
    1. Advertising

  2. On Thu, 18 Oct 2007 15:21:41 -0400, Gerard Brunick wrote:
    > Is there a way to do:
    >
    > s = "I like python %i%s of the time." print s % (99, "%")
    >
    > without having to pass in "%"?
    >
    > Thanks,
    > Gerard


    Just double-up the % sign, e.g. "I like python %i%% of the time."
     
    Daniel Lenski, Oct 22, 2007
    #2
    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. solartimba
    Replies:
    15
    Views:
    781
    red floyd
    Oct 20, 2003
  2. erikcw
    Replies:
    3
    Views:
    256
    Terry Reedy
    Apr 2, 2007
  3. slomo
    Replies:
    5
    Views:
    1,546
    Duncan Booth
    Dec 2, 2007
  4. Casey Hawthorne
    Replies:
    1
    Views:
    720
    Arne Vajhøj
    Mar 18, 2009
  5. Steve Grazzini
    Replies:
    2
    Views:
    117
    Steve
    Jul 17, 2003
Loading...

Share This Page