Right-Justifying Numeric Output

Facundo Batista facundo at taniquetil.com.ar
Fri Jan 26 11:16:28 EST 2007


Rich Shepard wrote:


> print '%2d   $%11.2f  $%10.2f  $%9.2f  $%9.2f' %(nper, pv, diff, ten, bonus)
>
> and I would like to have the output right justified in the specified field.

>>> "%7.2f..%5d"  % (2.3, 78)
'   2.30..   78'
>>> "%-7.2f..%-5d"  % (2.3, 78)
'2.30   ..78   '

Regards,

-- 
.   Facundo
.
Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/





More information about the Python-list mailing list