Printing a percent sign

John Machin sjmachin at lexicon.net
Mon Sep 25 20:24:53 EDT 2006


stephen at theboulets.net wrote:
> Thanks -- a percent escapes itself when using %-formatting.
>
> Stephen
>
> step... at theboulets.net wrote:
> > Hi all. How do I escape the "%" sign in a print statement so that it
> > prints? Thanks.
> >

The following methods of getting answers to problems can be handy if
it's non-peak hours on the net or your internet connection is
broken/slow :

1. Reasoning: How do you get a literal "'" into an SQL string constant?
How do you get a literal "\" into a Python string constant? How do you
get a literal "$" into some *x shell command lines? Do you detect a
pattern?

2. Inspecting the documentation: in this case, it says:
"""% <tab> No argument is converted, results in a "%" character in the
result. """
If that is not sufficiently clear, can you suggest how it might be
improved?

HTH generally,
John




More information about the Python-list mailing list