[Python] How to convert float into Hours Minutes Seconds?

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

  1. Stack

    Stack Membro Participativo

    I've values in float and I am trying to convert them into Hours:Min:Seconds but I've failed. I've followed the following post:

    Converting a float to hh:mm format

    For example I've got a value in float format:

    time=0.6

    result = '{0:02.0f}:{1:02.0f}'.format(*divmod(time * 60, 60))


    and it gives me the output:

    00:36


    But actually it should be like "00:00:36". How do I get this?

    Continue reading...

Compartilhe esta Página