Home > Article > Backend Development > What is the method to install and use chinesecalendar in Python?
This library is used to determine whether a certain day of a certain month of a certain year is a working day/holiday. Support extending the Spring Festival from 2004 to 2023, including 2020. Due to the holiday schedule for the following year, it depends on the schedule released by the State Council. Therefore, this project will generally release a new version after the State Council updates it. According to past experience, a new version is usually released around November every year.
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple chinesecalendar
# Determine whether April 30, 2018 is a holiday
# Determine whether a legal holiday is a holiday
import datetime # 判断 2018年4月30号 是不是节假日 from chinese_calendar import is_holiday, is_workday april_last = datetime.date(2022, 3, 23) print('is_holiday: ',is_holiday(april_last)) print('is_workday: ',is_workday(april_last)) # 判断法定节假日是不是调休 from chinese_calendar import is_in_lieu date01 = datetime.date(2022, 1, 29) date02 = datetime.date(2022, 2, 1) print('is_in_lieu: ',is_in_lieu(date02))
The above is the detailed content of What is the method to install and use chinesecalendar in Python?. For more information, please follow other related articles on the PHP Chinese website!