سؤال

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