Python计算日期间隔的天数
2021-04-15
import time
start_date = "2020-1-1"
end_date = "2021-1-1"
start_sec = time.mktime(time.strptime(start_date, '%Y-%m-%d'))
end_sec = time.mktime(time.strptime(end_date, '%Y-%m-%d'))
days = int((end_sec - start_sec) / 86400)
print(days)全都是函数调用
我也不是很懂这两个函数,但是反正看来start_sec和end_sec应该是时间戳
一天86400秒常识