获取目标时间距离现在多长时间
import time,datetime
time_new = '2020-5-30 23:40:00'
timeArray_new = time.strptime(time_new, "%Y-%m-%d %H:%M:%S")
print (str(timeArray_new.tm_year)+":"+str(timeArray_new.tm_mon))
timeStamp_new = int(time.mktime(timeArray_new))
print (timeStamp_new)
now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
timeArray_now = time.strptime(now, "%Y-%m-%d %H:%M:%S")
print (str(timeArray_now.tm_year)+":"+str(timeArray_now.tm_mon))
timeStamp_now = int(time.mktime(timeArray_now))
print (timeStamp_now)
time_delay = timeStamp_new - timeStamp_now
d = int(time_delay/(60*60*24))
h = int((time_delay%(60*60*24))/(60*60))
m = int((time_delay%(60*60*24))%(60*60)/60)
s = int((time_delay%(60*60*24))%(60*60)%60)
print(str(d)+"天"+str(h)+"时"+str(m)+"分"+str(s)+"秒")
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200509134340578.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3hpYW96aGV6aGUwNDcw,size_16,color_FFFFFF,t_70#pic_center)