quoting %

Cliff Wells clifford.wells at comcast.net
Wed Oct 13 07:53:35 EDT 2004


On Wed, 2004-10-13 at 13:32 +0200, Matthias Teege wrote:
> Moin,
> 
> I need a string like this "foo '%value%'" for a database query but
> print "'%%s%'"%value gives me TypeError: not all arguments converted
> during string formatting. How does I quote the "%" sign in this case?

You need to escape the extra percents:

print "'%%%s%%'" % value

Regards,
Cliff

-- 
Cliff Wells <clifford.wells at comcast.net>




More information about the Python-list mailing list