如下所示: import datetime t1 = datetime.datetime.strptime("2017-9-06 10:30:00", "%Y-%m-%d %H:%M:%S") t2 = datetime.datetime.strptime("2017-9-06 12:30:00", "%Y-%m-%d %H:%M:%S") interval_time = (t2 - t1).seconds # 输入的结果:7200 忽略微秒和天 total_interval_time = (t2 - t1).total_seconds() # 输出结果是: 7200.0 print (in