float print formatting
Neil Cerutti
horpner at yahoo.com
Tue Feb 13 10:07:33 EST 2007
On 2007-02-13, hg <hg at nospam.org> wrote:
> Neil Cerutti wrote:
>
>> On 2007-02-13, hg <hg at nospam.org> wrote:
>>> Hi,
>>>
>>> Considering the float 0.0, I would like to print 00.00.
>>>
>>> I tried '%02.02f' % 0.0 ... but I get 0.00
>>>
>>> Any clue ?
>>
>> Yes. How wide (total) is "0.00", compared to "00.00"?
>>
>> --
>> Neil Cerutti
>
> I do not get it
>
> s = '%02.02f' % 0.0
The first number after the percent is the minimum width specifier
for the ENTIRE field.
> s
>>> '0.00'
> len(s)
>>> 4
It is the MINIMUM width specifier for the entire field.
--
Neil Cerutti
The eighth-graders will be presenting Shakespeare's Hamlet in the church
basement on Friday at 7 p.m. The congregation is invited to attend this
tragedy. --Church Bulletin Blooper
More information about the Python-list
mailing list