Formatting floats in Python without superfluos zeros
Posted
by TarGz
on Stack Overflow
See other posts from Stack Overflow
or by TarGz
Published on 2010-03-14T00:27:39Z
Indexed on
2010/03/14
0:35 UTC
Read the original article
Hit count: 312
How to format a float so it does not containt the remaing zeros? In other words, I want the resulting string to be as short as possible..?
Like:
3 -> "3"
3. -> "3"
3.1 -> "3.1"
3.14 -> "3.14"
3.140 -> "3.14"
© Stack Overflow or respective owner