Proper number alignment

Joseph Wilhelm jwilhelm at outsourcefinancial.com
Thu Jun 20 14:22:11 EDT 2002


On Thu, 2002-06-20 at 11:05, mdk wrote:
> I am using \t\t (tabs) to align these numbers (disregard the math):
> 
> Total RAM                2,141,056
> Available RAM            12,934,032
> Used RAM                 1,024
> 
> But they are left justified and I need them right justified.
> 
> Any ideas?
> 
> Thanks.
> -- 
> http://mail.python.org/mailman/listinfo/python-list

Is this what you're looking for?

>>> print "%-20s %20s\n%-20s %20s\n%-20s %20s" % ( "Total RAM",
"2,141,056", "Available RAM", "12,934,032", "Used RAM", "1,024" )
Total RAM                       2,141,056
Available RAM                  12,934,032
Used RAM                            1,024


--Joseph Wilhelm






More information about the Python-list mailing list