Counting passed seconds

纵饮孤独 提交于 2019-12-11 11:03:30

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/8543725/counting-passed-seconds

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!