python获取前一天零点与二十四点的时间

now = time.time()
midnight = now - (now % 86400) + time.timezone
premidnight =midnight- 86400
nowmidnight = midnight - 1
itime = time.ctime(nowmidnight)

print(itime)

#time.strftime("%Y-%m-%d %H:%M %p", time.localtime())
year = int(time.strftime("%Y", time.localtime()))
month = int(time.strftime("%m", time.localtime()))
month = month-1
days=int(time.strftime("%d",time.localtime()))

你可能感兴趣的:(python获取前一天零点与二十四点的时间)