python 获取当天凌晨零点的时间戳方法
最近写python,遇到了一个问题,需要获取当日凌晨零点的时间戳,网上实在没有找到,自己手写了一个,有点挫
# -*- coding:utf-8 -*- import time now_time = int(time.time()) day_time = now_time - now_time % 86400 + time.timezone day_time_str = time.asctime(time.localtime(day_time)) print day_time print day_time_str import datetime today = datetime.date.today() today_time = int(time.mktime(today.timetuple())) print today_time
输出如下:
1518105600
Fri Feb 9 00:00:00 2018
1518105600
相关推荐
xinhao 2020-02-13
zhglinux 2020-01-12
逍遥友 2019-12-08
davidchang 2019-11-04
党薇 2019-05-14
liuxiaohua 2019-04-01
kikaylee 2019-04-01
奋斗的蜗牛 2019-03-28
katnisswuyuechen 2018-12-19
千锋 2018-05-22
Triagen 2017-12-11
zongzi00 2016-01-19
liugan 2017-10-20
lispython 2016-03-23
uglygirl 2015-05-15
Triagen 2015-04-23
PythonGCS 2015-03-13