What is precision of a number representation?
Random832
random832 at fastmail.com
Tue Jul 12 09:36:27 EDT 2016
On Tue, Jul 12, 2016, at 02:21, Steven D'Aprano wrote:
> If not, then what are the alternatives? Using str.format, how would
> you get the same output as this?
>
>
> py> "%8.4d" % 25
> ' 0025'
" %04d" % 25
"%8s" % ("%04d" % 25)
The latter (well, generally, "format it how you want and then use %*s to
put it in fixed columns") is something that I've actually *done*,
because it's easier to reason about.
More information about the Python-list
mailing list