How do I put % in a format sting?

wesley chun wescpy at gmail.com
Thu Oct 5 19:14:13 EDT 2006


as fredrik and others have mentioned, '%%' in a format string gives
you the single '%' in the string as desired.

however, in your specific application (database), it's best to avoid
using Python's string formatting unless that is the default provided
by your database adapter for the reasons that carsten mentioned,
namely the possibility of a SQL injection attack.  when dealing with
databases, it's always safest to let the adapter code format your
string for you.

good luck!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
    http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com



More information about the Python-list mailing list