mardi 3 mars 2015

Python String Formatting - float with given precision AND padded by zeros

I have looked at a couple of dozen similar questions - and I'm happy to just get a link to another answer - but I want to zero pad a floating point number in python 3.3



n = 2.02
print( "{?????}".format(n))
# desired output:
002.0200


The precision of the float is easy but I can't ALSO get the zero padding. What goes into the ????'s


Aucun commentaire:

Enregistrer un commentaire