1. 首页
  2. 数据库
  3. 其它
  4. Python时间差中seconds和total_seconds的区别详解

Python时间差中seconds和total_seconds的区别详解

上传者: 2020-12-31 17:19:16上传 PDF文件 32.79KB 热度 9次
如下所示: 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
下载地址
用户评论