题目:
Write a function, which takes a non-negative integer (seconds) as input and returns the time in a human-readable format (HH:MM:SS
)
HH
= hours, padded to 2 digits, range: 00 - 99MM
= minutes, padded to 2 digits, range: 00 - 59SS
= seconds, padded to 2 digits, range: 00 - 59
The maximum time never exceeds 359999 (99:59:59
)
You can find some examples in the test fixtures.
中文简介:
其实很简单,就是给你一个秒数,将其转化为小时:分钟:秒钟的形式返回
想法:
1、分钟为秒数整出60,小时为分钟整出60,秒钟为秒数整除60后的余数
2、判断各个是否<10是的话补0
3、转化字符串输出
实现:
def make_readable(seconds):
ss = str(seconds % 60) if (seconds % 60) > 9 else '0' + str(seco