I'm trying to format some numbers in Python in the following way:
(number) -> (formatted number)
1 -> 01
10 -> 10
1.1 -> 01.1
10.1 -> 10.1
1.1234 -> 01.1
What formatting specification could I use for that?
What I've tried: {:04.1f}
doesn't work correctly if there's no decimal part, while {:0>2}
only works for integers, {:0.2g}
comes close but doesn't add the leading zero and {:0>4.2g}
adds too many zeroes if there's no decimal part.