A fast, efficient Python library for generating country- and subdivision- (e.g.
state or province) specific sets of government-designated holidays on the fly.
It aims to make determining whether a specific date is a holiday as fast and
flexible as possible.
Install
The latest stable version can always be installed or updated via pip:
fromdatetimeimportdateimportholidaysus_holidays=holidays.US() # this is a dict# the below is the same, but takes a string:us_holidays=holidays.country_holidays('US') # this is a dictdate(2015, 1, 1) inus_holidays# Truedate(2015, 1, 2) inus_holidays# Falseus_holidays.get('2014-01-01') # "New Year's Day"
The HolidayBase dict-like class will also recognize date strings and Unix
timestamps:
Please see the documentation for additional examples and detailed
information.
Available Countries
We currently support 86 countries. The standard way to refer to a country is by
using its ISO 3166-1 alpha-2 code, the same used for domain names. The
following countries and their subdivisions are available:
Country
Code
Subdivisions Available
Angola
AO
None
Argentina
AR
None
Aruba
AW
None
Australia
AU
States and territories: ACT (default), NSW, NT, QLD, SA, TAS, VIC, WA
Use subd='Ext' to include holidays most people have off
Romania
RO
None
Russia
RU
None
Saudi Arabia
SA
None
Serbia
RS
None
Singapore
SG
None
Slovakia
SK
None
Slovenia
SI
None
South Africa
ZA
None
Spain
ES
Autonomous communities: AN (Andalucía), AR (Aragón), AS (Asturias), CB (Cantabria), CE (Ceuta), CL (Castilla y León), CM (Castilla La Mancha), CN (Canarias), CT (Cataluña), EX (Extremadura), GA (Galicia), IB (Islas Baleares), MC (Murcia), MD (Madrid), NC (Navarra), PV (País Vasco), RI (La Rioja), VC (Comunidad Valenciana)
Subdivisions: UK (default), England, Northern Ireland, Scotland, Wales. For Isle of Man use country code IM.
United States
US
States and territories: AL, AK, AS, AZ, AR, CA, CO, CT, DE, DC, FL, GA, GU, HI, ID, IL, IN, IA, KS, KY, LA, ME, MD, MH, MA, MI, FM, MN, MS, MO, MT, NE, NV, NH, NJ, NM, NY, NC, ND, MP, OH, OK, OR, PW, PA, PR, RI, SC, SD, TN, TX, UT, VT, VA, VI, WA, WV, WI, WY
Uruguay
UY
None
Uzbekistan
UZ
None
Venezuela
VE
None
Vietnam
VN
None
Zambia
ZM
None
Zimbabwe
ZW
None
Available Financial Markets
The standard way to refer to a financial market is to use its ISO 10383 MIC
(Market Identifier Code) as a "country" code when available. The
following financial markets are available:
请发表评论