原题
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.
我的解法
def make_readable(seconds):
h = seconds // 3600
seconds -= h * 3600
m = seconds // 60
seconds -= m * 60
s = seconds
return '%02d:%02d:%02d' % (h,m,s)
我觉得难点不多,但这道题在网站上难度系数还不低,费解...