problem with % operator on format string

vivek at cs.unipune.ernet.in vivek at cs.unipune.ernet.in
Thu Jun 26 00:50:06 EDT 2003


On Thu, Jun 26, 2003 at 04:04:23AM +0200, vald at valis.amber.eu.org 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





More information about the Python-list mailing list