python 日期时间计算、日期时间相减、日期时间间隔 作者:马育民 • 2021-08-13 22:54 • 阅读:10180 ``` import datetime def timeInterval(time1,time2): """ time1-time2 """ dt1=datetime.datetime.strptime(time1,'%Y-%m-%d %H:%M:%S') dt2=datetime.datetime.strptime(time2,'%Y-%m-%d %H:%M:%S') d=dt1-dt2 snd=d.total_seconds() return snd if __name__=="__main__": res=timeInterval("2018-01-03 11:23:18","2018-01-03 11:23:08") print(res) ``` 原文出处:http://malaoshi.top/show_1IX1fdv0hS6f.html