python获取当前时间到第二天凌晨剩余的秒数

  • Post author:
  • Post category:python


import datetime

def getRestSeconds():
    now = datetime.datetime.now()
    today_begin = datetime.datetime(now.year, now.month, now.day, 0, 0, 0)
    tomorrow_begin = today_begin + datetime.timedelta(days=1)
    rest_seconds = (tomorrow_begin - now).seconds
    print(rest_seconds)
    
getRestSeconds()

运行结果:

17827



版权声明:本文为qq_43509940原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。