문제

How can we count the number of seconds passed since the start of the day 0.00 ? Is there a module function or do we have to do it ourselves?

도움이 되었습니까?

해결책

from datetime import datetime, time

now = datetime.now()
beginning_of_day = datetime.combine(now.date(), time(0))
print (now - beginning_of_day).seconds

See docs for datetime module here.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top