String formatting with fixed width
Alexander Eisenhuth
newsuser at stacom-software.de
Fri Mar 16 09:19:56 EDT 2007
Hello alltogether,
is it possible to format stings with fixed width of let's say 7 character. T
need a floating point with 3 chars before dot, padded with ' ' and 3 chars after
dot, padded with '0'.
Followingh is my approach
>>> f = 21.1
>>> s = "%.03f" % f
>>> s
'21.100'
But there are missing ' '. How can I get that? (For bigger numbers than 999 they
might be cut: 1021 -> 021)
Alexander
More information about the Python-list
mailing list