PYTHON 13位时间戳
import datetime, time # -*- coding: utf-8 -*- def get_time_stamp13(datetime_obj): import datetime, time # 生成13时间戳 eg:1557842280000 datetime_str = datetime.datetime.strftime(datetime_obj, '%Y-%m-%d %H:%M:00') datetime_obj = datetime.datetime.strptime(datetime_str, '%Y-%m-%d %H:%M:00') print(datetime_obj) # 10位,时间点相当于从1.1开始的当年时间编号 date_stamp = str(int(time.mktime(datetime_obj.timetuple()))) # 3位,微秒 data_microsecond = str("%06d" % datetime_obj.microsecond)[0:3] date_stamp = date_stamp + data_microsecond return int(date_stamp) now_time = datetime.datetime.now() start_time = now_time - datetime.timedelta(minutes=2) end_time = now_time + datetime.timedelta(minutes=1) start_time_stamp = get_time_stamp13(start_time) end_time_stamp = get_time_stamp13(end_time) print(start_time_stamp) print(end_time_stamp)