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
原因
由于次年的節(jié)假日安排,取決于國務(wù)院發(fā)布的日程。 所以chinesecalendar項目一般會在國務(wù)院更新以后,發(fā)布新的版本。 按照以往的經(jīng)驗,一般是每年的 11月 前后發(fā)布新版本。
解決方法
pip install -U chinesecalendar
或者
pip install chinesecalendar==1.8.0
1.8.0取當(dāng)前chinesecalendar最新版本
附上chinesecalendar項目地址
chinesecalendar·PyPI
附錄:python chinese_calendar 工作日、假期日、調(diào)休日判斷
加載庫
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) # 是否節(jié)假日
OnHoliday, HolidayName = get_holiday_detail(date) # 是否節(jié)假日、節(jié)假日名稱
IsInlieu = is_in_lieu(date) # 是否調(diào)休(有待驗證)
print("是否工作日:",IsWorkday)
print("是否節(jié)假日:",IsHoliday)
print("是否節(jié)假日:",OnHoliday," || 節(jié)假日名稱:",HolidayName)
print(" 是否調(diào)休:",IsInlieu)
參考:https://pypi.org/project/chinesecalendar/
到此這篇關(guān)于python chinesecalendar報錯:“no available data for year {}, only year between [{}, {}] supported“的文章就介紹到這了,更多相關(guān)python chinesecalendar報錯內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
python爬不同圖片分別保存在不同文件夾中的實現(xiàn)
這篇文章主要介紹了python爬不同圖片分別保存在不同文件夾中的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-04-04
Python中reset_index()函數(shù)的使用
本文主要介紹了Python中reset_index()函數(shù)的使用,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-05-05
使用Python連接MySQL數(shù)據(jù)庫進行編程的步驟詳解
Python數(shù)據(jù)庫編程可以使用多種模塊與API,例如SQLite、MySQL、PostgreSQL等,本教程將重點介紹使用Python連接MySQL數(shù)據(jù)庫進行編程,需要的朋友可以參考下2023-06-06
解決Pytorch內(nèi)存溢出,Ubuntu進程killed的問題
這篇文章主要介紹了解決Pytorch內(nèi)存溢出,Ubuntu進程killed的問題,具有很好的參考價值,希望對大家有所幫助。2021-05-05
導(dǎo)入tensorflow時報錯:cannot import name ''abs''的解決
這篇文章主要介紹了導(dǎo)入tensorflow時報錯:cannot import name 'abs'的解決,文中介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10

