def convert_time_to_str(time):
#时间数字转化成字符串,不够10的前面补个0
if (time < 10):
time = '0' + str(time)
else:
time=str(time)
return time
def sec_to_data(y):
h=int(y//3600 % 24)
d = int(y // 86400)
m =int((y % 3600) // 60)
s = round(y % 60,2)
h=convert_time_to_str(h)
m=convert_time_to_str(m)
s=convert_time_to_str(s)
d=convert_time_to_str(d)
# 天 小时 分钟 秒
return d + ":" + h + ":" + m + ":" + s
a=sec_to_data(86461.6) #86461秒
print(a)
输出结果,单位是,天:小时:分钟:秒
01:00:01:01.6
Process finished with exit code 0