How do I convert seconds to hours, minutes and seconds?

前端 未结 12 2114
执笔经年
执笔经年 2020-11-22 11:00

I have a function that returns information in seconds, but I need to store that information in hours:minutes:seconds.

Is there an easy way to convert the seconds to

12条回答
  •  花落未央
    2020-11-22 11:45

    You can use datetime.timedelta function:

    >>> import datetime
    >>> str(datetime.timedelta(seconds=666))
    '0:11:06'
    

提交回复
热议问题