float print formatting

H

hg

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 ?

Thanks,

hg
 
H

hg

NOSPAM said:
hg skrev:
Try this:

a = 45.45 # the floating number

print "some text",
print a,
print "some text again"

or just this:

print "some text",
print 45.45,
print "some text again"

Hope it helped :D

Andreas

Sorry,

must be very slow or not enough coffee yet ... my purpose is to display a
justified report, so I format my floats into strings which I next draw in a
bitmap.

hg
 
H

hg

Neil said:
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

;-) I like that !

hg
 
H

hg

Grant said:
^^
That's the specifierfor how many total columns you want to use
(including the decimal point and all digits to either side).

'00.00'

--
Grant Edwards grante Yow! Yow!! "Janitor
at trapped in sewer uses
ESP
visi.com to find decayed
burger"!!

Thanks
 
G

Guest

hg skrev:
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 ?

Thanks,

hg
Try this:

a = 45.45 # the floating number

print "some text",
print a,
print "some text again"

or just this:

print "some text",
print 45.45,
print "some text again"

Hope it helped :D

Andreas
 
N

Neil Cerutti

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"?
 
P

Peter Otten

hg said:
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 ?

The first integer specifies the total width:
'00.00'

Peter
 
G

Grant Edwards

Hi,

Considering the float 0.0, I would like to print 00.00.

I tried '%02.02f' % 0.0 ... but I get 0.00
^^
That's the specifierfor how many total columns you want to use
(including the decimal point and all digits to either side).
Any clue ?
'00.00'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top