算时间过去了几天几小时
import time true_time = time.mktime(time.strptime('2020-01-01 08:00:00', '%Y-%m-%d %H:%M:%S')) time_now = time.mktime(time.strptime('2020-03-01 08:00:00', '%Y-%m-%d %H:%M:%S')) dif_time = time_now - true_time struct_time = time.gmtime(dif_time) print('过去了%d年%d月%d天%d小时%d分钟%d秒' % (struct_time.tm_year - 1970, struct_time.tm_mon - 1, struct_time.tm_mday - 1, struct_time.tm_hour, struct_time.tm_min, struct_time.tm_sec))