[Tutor] Making table
Carroll, Barry
Barry.Carroll at psc.com
Mon Mar 19 18:40:31 CET 2007
> -----Original Message-----
> Date: Mon, 19 Mar 2007 11:53:06 -0400
> From: Kent Johnson <kent37 at tds.net>
> Subject: Re: [Tutor] Making table
> To: tutor at python.org
> Message-ID: <45FEB1E2.1000501 at tds.net>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Dave Kuhlman wrote:
> > Try ljust and rjust. They are string functions/methods and are
> > described here: http://docs.python.org/lib/string-methods.html
> >
> > Something like the following might work for you:
> >
> > In [1]: value = 3.45678
> > In [2]: ("%0.3f" % value).rjust(10)
> > Out[2]: ' 3.457'
>
> Most string formatting conversions allow you to specify a width
> directly. For example,
> In [61]: value = 3.45678
> In [63]: "%10.3f" % value
> Out[63]: ' 3.457'
>
> Kent
>
What if one wished to align the values in each column at the decimal
point? Is there a simple means to do this in Python, or would one need
to write a new function?
Regards,
Barry
barry.carroll at psc.com
541-302-1107
________________________
We who cut mere stones must always be envisioning cathedrals.
-Quarry worker's creed
More information about the Tutor
mailing list