[Python] 纯文本查看 复制代码 # -*- coding: utf-8 -*-
import time
from datetime import datetime
def gettimestamp(x):
timeArray = time.strptime(x,'%Y%m%d')
return int(time.mktime(timeArray))
def formattime(timeStamp):
timeArray = time.localtime(timeStamp)
otherStyleTime = time.strftime('%Y%m%d', timeArray)
return otherStyleTime
date1='20190101-8'
date2='20190103-3'
date1split = date1.split('-')
date2split = date2.split('-')
nowdate = gettimestamp(date1split[0])
date1count = int(date1split[1])
utildate = gettimestamp(date2split[0])
date2count = int(date2split[1])
ret = []
flag = 0
while nowdate<=utildate:
if(flag==0):
flag=1
for i in range(date1count,10):
ret.append(formattime(nowdate)+'-'+str(i))
elif(nowdate==utildate):
for i in range(0,date2count):
ret.append(formattime(nowdate)+'-'+str(i))
else:
for i in range(0,10):
ret.append(formattime(nowdate)+'-'+str(i))
nowdate += 86400
print(ret)
|