python 计时时间格式化
2020-10-10
python
1590
import time start = 1602319215 t1 = int(time.time()) n = t1-start def format_time(n,time_format="{0}天{1}小时{2}分{3}秒"): day_num = int(n / 86400) t1 = n % 86400 hour_num = int(t1 / 3600) t2 = t1 % 3600 minute_num = int(t2 / 60) minute_num = str(minute_num+100)[1:] second_num = t2 % 60 second_num = str(second_num + 100)[1:] return time_format.format(day_num,hour_num,minute_num,second_num) print(format_time(3602))
很赞哦! (0)
相关文章
文章评论
-
-
-
0条评论