String formatting characters - looking for details

Fredrik Lundh fredrik at pythonware.com
Thu Feb 8 07:40:21 CET 2001


Martin Bless wrote:
> (1) Where can I find some more details about the string formatting
> characters?

your nearest C/Unix manual.  or the Python 2.1 docs:

http://python.sourceforge.net/devel-docs/lib/typesseq-strings.html

> (2) How  I print hex values with zeros padded left, like 0F or 0A?
> print '%X' % 15  # two digits, wanted

print "%02X" % 15

> (3) This is from the Python docs - I'm looking for more information on
> how to use the formatting characters.

searching the net for "sprintf" brings up an infinite number
of manual pages.  (fwiw, the perl manual page says these
formatting codes are "universally known"...)

Cheers /F





More information about the Python-list mailing list