Using Python to count the number of business days in a month?

后端 未结 6 838
南旧
南旧 2021-01-05 18:27

I am trying to write a Python script that will calculate how many business days are in the current month. For instance if month = August then businessDays

6条回答
  •  -上瘾入骨i
    2021-01-05 18:50

    This is relatively simple, just break it down into steps:

    1. You need to be able to loop through the days in a month.
    2. You need to be able to determine the day of a week that any given date falls on. Wikipedia lists some methods.
    3. Then you need only flag days of the week as business days or not.

    Combine these steps and you'll have a working method.

提交回复
热议问题