python chinesecalendar报错:"no available data for year {}, only year between [{}, {}] supported"
作者:hmz0303hf
这篇文章主要介绍了python chinesecalendar报错:“no available data for year {}, only year between [{}, {}] supported“的相关知识,需要的朋友可以参考下
python chinesecalendar报错:“no available data for year {}, only year between [{}, {}] supported“
报错
“no available data for year {}, only year between [{}, {}] supported”.
NotImplementedError: no available data for year 2023, only year between [2004, 2022] supported
原因
由于次年的节假日安排,取决于国务院发布的日程。 所以chinesecalendar项目一般会在国务院更新以后,发布新的版本。 按照以往的经验,一般是每年的 11月 前后发布新版本。
解决方法
pip install -U chinesecalendar
或者
pip install chinesecalendar==1.8.0
1.8.0取当前chinesecalendar最新版本
附上chinesecalendar项目地址
chinesecalendar·PyPI
附录:python chinese_calendar 工作日、假期日、调休日判断
加载库
import datetime from chinese_calendar import is_workday, is_holiday,get_holiday_detail,is_in_lieu
小案例
date = datetime.date(2022, 1, 1) # 2022-01-01 周五 元旦 IsWorkday = is_workday(date) # 是否工作日 IsHoliday = is_holiday(date) # 是否节假日 OnHoliday, HolidayName = get_holiday_detail(date) # 是否节假日、节假日名称 IsInlieu = is_in_lieu(date) # 是否调休(有待验证) print("是否工作日:",IsWorkday) print("是否节假日:",IsHoliday) print("是否节假日:",OnHoliday," || 节假日名称:",HolidayName) print(" 是否调休:",IsInlieu)
参考:https://pypi.org/project/chinesecalendar/
到此这篇关于python chinesecalendar报错:“no available data for year {}, only year between [{}, {}] supported“的文章就介绍到这了,更多相关python chinesecalendar报错内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!