且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

两个日期之间的天数,不包括周末

更新时间:2023-01-31 14:10:13

我认为最干净的解决方案是使用 numpy 函数 busday_count

I think the cleanest solution is to use the numpy function busday_count

import numpy as np
import datetime as dt

start = dt.date( 2014, 1, 1 )
end = dt.date( 2014, 1, 16 )

days = np.busday_count( start, end )