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

  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. 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. solartimba
    Replies:
    15
    Views:
    1,050
    red floyd
    Oct 20, 2003
  2. erikcw
    Replies:
    3
    Views:
    301
    Terry Reedy
    Apr 2, 2007
  3. slomo
    Replies:
    5
    Views:
    2,099
    Duncan Booth
    Dec 2, 2007
  4. Casey Hawthorne
    Replies:
    1
    Views:
    915
    Arne Vajhøj
    Mar 18, 2009
  5. Sam Roberts
    Replies:
    10
    Views:
    293
    Sam Roberts
    Mar 20, 2005
  6. Steve Grazzini
    Replies:
    2
    Views:
    195
    Steve
    Jul 17, 2003
  7. Ted Byers
    Replies:
    23
    Views:
    740
    Peter J. Holzer
    Nov 15, 2008
  8. Jake Barnes
    Replies:
    15
    Views:
    302
    Thomas 'PointedEars' Lahn
    Feb 7, 2006
Loading...