%s %x %0.2f %04d

Narayan Desai desai at mcs.anl.gov
Fri Sep 8 23:37:10 CEST 2000


It basically works like printf.
>>> print "%s %s %s"%("here","it","is")
here it is
 -nld

>>>>> "Brendhan" == Brendhan Horne <brendhan at bellsouth.net> writes:

Brendhan> In the beginners instruction manual it states: There are
Brendhan> other letters that can be placed after the % markers. Some
Brendhan> of those include:
Brendhan> %s- for string x- for hexadecimal number 0.2f- for a real
Brendhan> %number with a maximum of 2 decimal places 04d- pad the
Brendhan> %number out to 4 digits with 0's


Brendhan> That is nice but it gives no examples of how to use them. I
Brendhan> tried some of the basics
>>>> print 7%s2
Brendhan> Got an error
>>>> print 7 %s 2
Brendhan> Got an error So if someone could show me some basic one
Brendhan> liners that use the modulus with the suffix I would
Brendhan> appreciate it.  Remember when you do this you are dealing
Brendhan> with someone who has no knowledge of computer language.


Brendhan> -- Thanks, Brendhan






More information about the Python-list mailing list