计算时间差
1 import time 2 true_time=time.mktime(time.strptime('2017-09-11 08:30:00','%Y-%m-%d %H:%M:%S')) 3 time_now=time.mktime(time.strptime('2017-09-12 11:00:00','%Y-%m-%d %H:%M:%S')) 4 dif_time=time_now-true_time 5 struct_time=time.gmtime(dif_time) 6 print('过去了%d年%d月%d天%d小时%d分钟%d秒'%(struct_time.tm_year-1970,struct_time.tm_mon-1, 7 struct_time.tm_mday-1,struct_time.tm_hour, 8 struct_time.tm_min,struct_time.tm_sec))