Re: problem with % operator on format string

Discussion in 'Python' started by vivek@cs.unipune.ernet.in, Jun 26, 2003.

  1. Guest

    On Thu, Jun 26, 2003 at 04:04:23AM +0200, wrote:
    >
    > hello,
    > i just subscribed to this list, so first i'd like to greet all of you :)
    > i've recently discovered this great language and now i'm coding alot in
    > it. today i ran into some problem with % operator on strings.
    >
    > i have some database query, which i want to format nicely. it looks like:
    >
    > query = "select date(xxx, '\%d') from yyy where xxx
    > like '%s%s\%'" % (year, month)
    >
    > so it should produce something like that (year=2003, month=06)
    >
    > select date(xxx, '%d') from yy where xxx like '200306%'
    >
    > arguments, even if i (as you see) use an escape character '\' before %d.


    use '%%d' instead of '\%d'

    regrads
    Vivek Kumar
     
    , Jun 26, 2003
    #1
    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. Brian Candy
    Replies:
    2
    Views:
    1,205
    Janaka
    Feb 18, 2004
  2. ankur
    Replies:
    1
    Views:
    13,054
    Jan =?UTF-8?B?VGhvbcOk?=
    Aug 27, 2007
  3. Chris Angelico
    Replies:
    3
    Views:
    177
    Mark Lawrence
    Mar 1, 2013
  4. Peter Otten
    Replies:
    0
    Views:
    149
    Peter Otten
    Feb 28, 2013
  5. Rick Johnson
    Replies:
    0
    Views:
    154
    Rick Johnson
    Feb 28, 2013
Loading...

Share This Page