Как я могу преобразовать секунды в часы, минуты и секунды?

что-то вроде: -

SELECT * FROM
(SELECT ifnull(uID,0) as uID from Class) T1
   LEFT OUTER JOIN
 (SELECT ifnull(pID,0) as pID from University) T2
   ON T1.uID = T2.pID
401
задан Peter Mortensen 29 October 2018 в 23:35
поделиться

3 ответа

You can use datetime.timedelta function:

>>> import datetime
>>> str(datetime.timedelta(seconds=666))
'0:11:06'
662
ответ дан 22 November 2019 в 23:22
поделиться

By using the divmod() function, which does only a single division to produce both the quotient and the remainder, you can have the result very quickly with only two mathematical operations:

m, s = divmod(seconds, 60)
h, m = divmod(m, 60)

And then use string formatting to convert the result into your desired output:

print('{:d}:{:02d}:{:02d}'.format(h, m, s)) # Python 3
print(f'{h:d}:{m:02d}:{s:02d}') # Python 3.6+
591
ответ дан 22 November 2019 в 23:22
поделиться

division = 3623 // 3600 #to hours
division2 = 600 // 60 #to minutes
print (division) #write hours
print (division2) #write minutes

пз Мой код непрофессиональный

-1
ответ дан 22 November 2019 в 23:22
поделиться
Другие вопросы по тегам:

Похожие вопросы: