[Python] Truncate to three decimals in Python

Discussão em 'Python' iniciado por Stack, Julho 9, 2025.

  1. Stack

    Stack Membro Participativo

    How do I get 1324343032.324?

    As you can see below, the following do not work:

    >>1324343032.324325235 * 1000 / 1000
    1324343032.3243253
    >>int(1324343032.324325235 * 1000) / 1000.0
    1324343032.3239999
    >>round(int(1324343032.324325235 * 1000) / 1000.0,3)
    1324343032.3239999
    >>str(1324343032.3239999)
    '1324343032.32'

    Continue reading...

Compartilhe esta Página