我只需要数学运算符就可以做到这一点,但是我总是在领域中得到高得离谱的数字。
def main():
seconds = int(input('Seconds to be converted? '))
days = seconds / 86400
seconds = seconds - (days * 86400)
hours = seconds / 3600
seconds = seconds - (hours * 3600)
minutes = seconds / 60
seconds = seconds - (minutes * 60)
print('-------------')
print('You entered: ', seconds)
print('')
print('The converted time is: ', format(days, '1.0f'), ':', format(hours, '1.0f'), ':', format(minutes, '1.0f'), ':', format(seconds, '1.0f'))
Run Code Online (Sandbox Code Playgroud) python-3.x ×1