Home > Backend Development > Python Tutorial > What is the method to install and use chinesecalendar in Python?

What is the method to install and use chinesecalendar in Python?

王林
Release: 2023-05-19 19:19:11
forward
2146 people have browsed it

Basic usage

Introduction to chinesecalendar

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.

Installation of chinesecalendar

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple chinesecalendar

What is the method to install and use chinesecalendar in Python?

chinesecalendarHow to use

Basic usage

# 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))
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template