秒 与 时:分:秒的互换

+++++++++++将秒变成时分秒+++++++++++++
seconds = 32100
m, s = divmod(seconds, 60)
h, m = divmod(m, 60)
time = ("%d:%02d:%02d" % (h, m, s))


++++++++++将时分秒变成秒++++++++++
st = "08:30:30"
def t2s(t):
h,m,s = t.strip().split(":") return int(h) * 3600 + int(m) * 60 + int(s)
print(t2s(st))
posted @ 2019-10-23 17:47  关美丽  阅读(294)  评论(0编辑  收藏  举报