Top.Mail.Ru
Python
? ?
LiveJournal for python.
View:Personal Journal.
View:Friends.
View:Calendar.
Missed some entries? Then simply jump to the previous day or the next day.

Saturday, February 7th, 2004

Subject:Padding floats before decimal point
Time:2:17 pm.
Mood:Image frustrated.

I have a float. I want to format said float so that it is zero-padded to two digits before the decimal point. The number of digits after does not matter (yet). You can zero-pad integers with "%.2d" % i. However, "%.2f" % f applies to precision after the decimal point. The manual doesn't seem to state any way to get this to apply to the digits before it. Is there any way?

Comments: Read 2 orAdd Your Own.

LiveJournal for python.

View:User Info.
View:Friends.
View:Calendar.
View:Memories.
Missed some entries? Then simply jump to the previous day or the next day.

Image