python 获取当天凌晨零点的时间戳

python 获取当天凌晨零点的时间戳

 

 https://blog.csdn.net/yun__yang/article/details/79299101

最近写python,遇到了一个问题,需要获取当日凌晨零点的时间戳,网上实在没有找到,自己手写了一个,有点挫

 
  1. # -*- coding:utf-8 -*-

  2. import time

  3.  
  4. now_time = int(time.time())

  5. day_time = now_time - now_time % 86400 + time.timezone

  6. day_time_str = time.asctime(time.localtime(day_time))

  7. print day_time

  8. print day_time_str

  9.  
  10. import datetime

  11. today = datetime.date.today()

  12. today_time = int(time.mktime(today.timetuple()))

  13.  

你可能感兴趣的:(Python)