%s %x %0.2f %04d

Patrick Phalen python-list at teleo.net
Fri Sep 8 20:32:23 EDT 2000


[Brendhan Horne, on Fri, 08 Sep 2000]
:: In the beginners instruction manual it states:
:: There are other letters that can be placed after the % markers. Some of
:: those include:
:: %s- for string
:: %x- for hexadecimal number
:: %0.2f- for a real number with a maximum of 2 decimal places
:: %04d- pad the number out to 4 digits with 0's
:: 
:: 
:: That is nice but it gives no examples of how to use them. I tried some of
:: the basics
:: >>> print 7%s2
:: Got an error
:: >>> print 7 %s 2
:: Got an error
:: So if someone could show me some basic one liners that use the modulus with
:: the suffix I would appreciate it.  Remember when you do this you are dealing
:: with someone who has no knowledge of computer language.


Don't know what document you refer to when you mention "the beginner's
instruction manual."

Anyway, probably the reason there aren't more examples is that this
stuff just mirrors the usage of the printf format identifiers as used
in the C programming language. So you can refer to any good printf
discussion to learn more.

Here's one: http://www.gator.net/~garyg/C/FUNCTIONS/format.html




More information about the Python-list mailing list