日本蟒蛇节
holiday-jp的Python项目详细描述
假日jp-python
日本Python节
安装
pip install holiday-jp
依赖性
pip3 install -r requirements.txt
使用https://github.com/holiday-jp/holiday_jp中的数据集
测试
python3 -m unittest holiday_jp.test
对于dev
使用python 3.6在linux上构建
生成命令:
python setup.py sdist
或
运行/生成.sh 构建dist/目录中提供的包
替代安装
下载发行版并按以下方式安装: pip3安装holiday_jp-xxx.tar.gz
用法
from holiday_jp import HolidayJp
if HolidayJp('1990-01-01').is_holiday:
print('True')
work with date
import datetime
from holiday_jp import HolidayJp
if HolidayJp(datetime.date.today()).is_holiday:
print('False')
else:
print('True')
# Between return holidays between 2 dates in text
holidays = HolidayJp.between('2009-01-01', '2009-01-31')
new_year_day = holidays[0]
self.assertEqual(datetime.date(year=2009, month=1, day=1), new_year_day.date_obj)
self.assertEqual('元日', new_year_day.name)
# Or date object
holidays = HolidayJp.between(datetime.date(year=2008, month=12, day=23), datetime.date(year=2009, month=1, day=12))
有关更多用法,请检查unit test holiday\u jp/test.py