Printing a percent sign

Fredrik Lundh fredrik at pythonware.com
Mon Sep 25 16:47:27 EDT 2006


stephen at theboulets.net wrote:

> Hi all. How do I escape the "%" sign in a print statement so that it
> prints? Thanks.

print doesn't do anything with percent signs:

 >>> print "%"
%

if you're doing string formatting using the "string % tuple" operator, 
use two percent signs to get a percent sign in the output:

 >>> print "%s: %d%%" % ("level", 48)
level: 48%

</F>




More information about the Python-list mailing list