下载第三方模块
pip install python-dateutil
def time_diff(t1,t2): t1 = parse(t1) t2 = parse(t2) ts = (t2-t1).total_seconds() int_ts = int(ts/60) return int_ts print(time_diff('2021-11-23 22:43:55','2021-11-23 22:44:55'))
seconds:除去天数、小时后剩余的秒数
total_seconds: 总秒数,包含天、小时转换后的秒数
days:仅包含天,时分秒会被抛弃