📜  将秒转换为小时 python 代码示例

📅  最后修改于: 2022-03-11 14:45:42.334000             🧑  作者: Mango

代码示例1
method = a
import datetime
str(datetime.timedelta(seconds=666))
'0:11:06'

method = b
def convert(seconds):
    seconds = seconds % (24 * 3600)
    hour = seconds // 3600
    seconds %= 3600
    minutes = seconds // 60
    seconds %= 60      
    return "%d:%02d:%02d" % (hour, minutes, seconds)