string formatting using the % operator
harold fellermann
harold.fellermann at upf.edu
Mon Jun 13 11:34:04 EDT 2005
> to return 'WHERE name LIKE %smith%' I have tried using escapes,
> character codes for the % sign, and lots of other gyrations with no
> success. The only thing that works is if I modify searchterm first:
>
> searchterm = 'smith'
> searchterm ='%'+'smith'+'%'
> sql += 'WHERE name LIKE %s' % searchterm
>
> Any Ideas?
>>> "%%%s%%" % "here you go"
'%here you go%'
Cheers,
- harold -
--
If your only tool is a hammer, every problem looks like a nail.
--
More information about the Python-list
mailing list