Python判断指定日期是不是法定节假日
Python判断指定⽇期是不是法定节假⽇判断⼀个⽇期是否为⼯作⽇、节假⽇,有⼀个现成的库函数:chinesecalendar
1、安装
靠谱的搬家公司pip3 install chinesecalendar
2、代码⽰例
demo.py
1from datetime import datetime
2from chinese_calendar import is_workday
3
4
5def isWorkdays(date_value):
6  """
起泡胶怎么做简单
7  # 判断是否是法定节假⽇
8  """
9  if is_workday(date_value):
10    print("{}是⼯作⽇".format(date_value))
11  else:
12    print("{}是休息⽇".format(date_value))
伤感繁体签名
13
14# 当前⽇期
给客户的中秋祝福语15date_1 = w().date()
16print("date_1: {}, type: {}".format(date_1, type(date_1)))
17
18isWorkdays(date_1)关于清明的作文600字
19
20# ⼈⼯输⼊⽇期
21date_2 = datetime.strptime("2022-03-19", '%Y-%m-%d').date()
高考寄语或鼓励的话简短202222print("date_2: {}, type: {}".format(date_2, type(date_2)))
23
24isWorkdays(date_2)
运⾏结果:
1date_1: 2022-02-18, type: <class 'datetime.date'>
22022-02-18是⼯作⽇
3date_2: 2022-03-19, type: <class 'datetime.date'>
42022-03-19是休息⽇
参考:

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。