python判断2018/2019年的某天是否是节假日

2019-01-25 09:15:00 by wst

python小组件

网上找了半天也没找到可用的,没一个省心的。
无奈之下只好自己动手,丰衣足食!

hol:节日,work:被调休的工作日

 

返回结果:

  • -1:报错
  • 0: 工作日
  • 1: 周末
  • 2: 节日
"""
Author: deepinwst
Email: movingheart000@gmail.com
Date: 19-01-25 下午1:56
"""

import datetime
import time

def holiday(d, s="2018-01-01", e="2019-12-31"):
    # 节假日
    hol = {"2018-01-01", "2018-02-15", "2018-02-16", "2018-02-17", "2018-02-18", "2018-02-19", "2018-02-20",
           "2018-02-21", "2018-04-05", "2018-04-06", "2018-04-07", "2018-04-29", "2018-04-30", "2018-05-01"
           "2018-06-16", "2018-06-17", "2018-06-18", "2018-09-22", "2018-09-23", "2018-09-24", "2018-10-01",
           "2018-10-02", "2018-10-03", "2018-10-04", "2018-10-05", "2018-10-06", "2018-10-07", "2018-12-30",
           "2018-12-31", "2019-01-01", "2019-02-04", "2019-02-05", "2019-02-06", "2019-02-07", "2019-02-08",
           "2019-02-09", "2019-02-10", "2019-04-05", "2019-04-06", "2019-04-07", "2019-05-01", "2019-06-07",
           "2019-06-08", "2019-06-09", "2019-09-13", "2019-09-14", "2019-09-15", "2019-10-01", "2019-10-02",
           "2019-10-03", "2019-10-04", "2019-10-05", "2019-10-06", "2019-10-07"}
    # 调休日
    work = {"2018-02-11", "2018-02-24", "2018-04-08", "2018-04-28", "2018-09-29", "2018-09-30", "2018-12-29",
            "2019-02-02", "2019-02-03", "2019-09-29"}
    s1 = datetime.datetime.strptime(s, '%Y-%m-%d')
    e1 = datetime.datetime.strptime(e, '%Y-%m-%d')
    if not isinstance(d, str):
        print("Please input string date")
        return -1
    else:
        d1 = datetime.datetime.strptime(d, '%Y-%m-%d')
        if d1 > e1 or d1 < s1:
            print("not in 2018/2019 year")
            return -1
        elif d in hol:
            return 2
        elif d in work:
            return 0
        elif d1.weekday() in (5, 6):
            return 1
        else:
            return 0


if __name__ == "__main__":
    day = "2018-10-14"
    print(holiday(day))

 


Comments(130) Add Your Comment

Ghagmn
order atorvastatin 80mg without prescription <a href="https://lipiws.top/">buy lipitor pills</a> lipitor 10mg cost
Yvbdfh
buy cipro 1000mg online cheap - <a href="https://metroagyl.top/cefaclor/">order cephalexin generic</a> augmentin 375mg cost
Wzrdyo
buy ciprofloxacin online cheap - <a href="https://cipropro.top/gemyambutol/">ethambutol 1000mg pill</a> buy augmentin 625mg pills
Sfmldg
purchase flagyl online cheap - <a href="https://metroagyl.top/keflexcapsule/">buy amoxil pill</a> azithromycin uk
Jdslhy
buy ciplox 500mg pills - <a href="https://septrim.top/chloromycetin/">cost chloramphenicol</a> order generic erythromycin
Obtjes
buy valtrex 1000mg pill - <a href="https://gnantiviralp.com/zovirax/">zovirax order online</a> buy acyclovir medication
Kcfuvo
ivermectin 3 mg without prescription - <a href="https://keflexin.top/ceftin/">ceftin pill</a> order generic tetracycline 500mg
Kmrzfb
buy flagyl 200mg generic - <a href="https://metroagyl.top/">brand metronidazole 200mg</a> zithromax us
Wsjklg
acillin tablet <a href="https://ampiacil.top/">ampicillin generic</a> amoxil uk
Mdxxvz
furosemide medication - <a href="https://antipathogenc.com/atacand/">candesartan order</a> order capoten 25mg sale
Mzanke
glycomet 500mg sale - <a href="https://gnantiacidity.com/">purchase metformin for sale</a> buy lincomycin 500mg
Kqskvr
zidovudine online buy - <a href="https://canadiangnp.com/zyloprim/"></a> zyloprim 300mg uk
Renusn
clozapine 50mg generic - <a href="https://genonlinep.com/pepcid/">cost famotidine 20mg</a> pepcid 40mg tablet
Eyvgtr
quetiapine buy online - <a href="https://gnkantdepres.com/">buy seroquel for sale</a> buy eskalith pills for sale
Gdwxdr
order hydroxyzine 25mg - <a href="https://antdepls.com/">hydroxyzine online buy</a> amitriptyline online order
Aqgbzt
order clomipramine 25mg - <a href="https://antdeponline.com/celexa/">celexa sale</a> purchase doxepin online
Tzfykj
amoxil tablets - <a href="https://atbioxotc.com/ceftin/">buy ceftin 250mg without prescription</a> cipro 1000mg tablet
Xodmvp
augmentin 1000mg for sale - <a href="https://atbioinfo.com/">purchase amoxiclav online</a> order ciprofloxacin 1000mg sale
Bvxfgg
cleocin cost - <a href="https://cadbiot.com/chloramphenicol/">buy chloromycetin no prescription</a> cheap chloromycetin pill
Hodzox
azithromycin 250mg cost - <a href="https://gncatbp.com/aciprofloxacin/">ciprofloxacin pill</a> buy ciplox online cheap
Jsudtn
oral ventolin - <a href="https://antxallergic.com/cvallegra/">order generic allegra</a> brand theophylline 400mg
Qtkcuf
ivermectin - <a href="https://antibpl.com/">stromectol australia</a> order cefaclor 250mg online
Vwsbfp
buy cheap desloratadine - <a href="https://rxtallerg.com/ventolinpill/">purchase ventolin for sale</a> strongest over the counter allergy
Szltvh
medrol pills - <a href="https://ntallegpl.com/montelukast/">order singulair 10mg generic</a> order azelastine 10ml generic
Slmpik
glyburide where to buy - <a href="https://prodeprpl.com/">buy glyburide pills</a> forxiga brand
Ehakwc
repaglinide 2mg usa - <a href="https://depressinfo.com/jardiance25/">buy cheap jardiance</a> order jardiance 10mg generic
Kxrhfr
buy glucophage 1000mg without prescription - <a href="https://arxdepress.com/losartan25/">buy cheap cozaar</a> buy generic acarbose online
Ucpzxd
terbinafine for sale - <a href="https://treatfungusx.com/">terbinafine tablet</a> buy grifulvin v no prescription
Zecezl
cost rybelsus 14mg - <a href="https://infodeppl.com/">semaglutide over the counter</a> DDAVP ca
Glcdpf
nizoral price - <a href="https://antifungusrp.com/clotrithasone/">buy lotrisone cream</a> buy itraconazole 100mg pills
Exxhbc
digoxin 250mg ca - <a href="https://blpressureok.com/avalidemed/">buy avapro tablets</a> buy furosemide sale diuretic
Ocqacc
buy famvir for sale - <a href="https://amvinherpes.com/acyclovircream/">zovirax 400mg price</a> valcivir medication
Kwgbdp
order microzide - <a href="https://norvapril.com/bisoprolol/">bisoprolol 10mg for sale</a> buy zebeta without prescription
Orbkab
lopressor uk - <a href="https://bloodpresspl.com/hyzaar/">buy cozaar 25mg online</a> adalat pill
Kishjv
where to buy nitroglycerin without a prescription - <a href="https://nitroproxl.com/valsartan/">order diovan 160mg generic</a> cost diovan
Xvyptk
crestor online stage - <a href="https://antcholesterol.com/">rosuvastatin pills train</a> caduet pills raise
Emdcgt
zocor report - <a href="https://canescholest.com/">simvastatin invite</a> lipitor almost
Mqcadv
viagra professional online counter - <a href="https://edsildps.com/superkamagra/">super kamagra hurry</a> levitra oral jelly lift
Ddwpup
dapoxetine hotel - <a href="https://promedprili.com/sildigra/">sildigra league</a> cialis with dapoxetine computer
Lgrfej
cenforce online device - <a href="https://xcenforcem.com/silagrasildenafil/"></a> brand viagra plate
Ltwodm
brand cialis patch - <a href="https://probrandtad.com/">brand cialis worship</a> penisole receive
Zjunzg
cialis soft tabs online intent - <a href="https://supervalip.com/cialissuperactive/">cialis super active pills ordinary</a>1 viagra oral jelly online shriek
Dnohmi
brand cialis thousand - <a href="https://probrandtad.com/zhewitra/">zhewitra because</a> penisole fool
Ipodup
cialis soft tabs pills darkness - <a href="https://supervalip.com/cavertapills/">caverta pills fond</a> viagra oral jelly online noise
Nmbttx
cenforce online bid - <a href="https://xcenforcem.com/silagrasildenafil/"></a> brand viagra pills represent
Ieffdj
acne treatment border - <a href="https://placnemedx.com/">acne medication where</a> acne treatment hedge
Hbpkgz
inhalers for asthma repeat - <a href="https://bsasthmaps.com/">asthma treatment nephew</a> inhalers for asthma mill
Bzmrbf
uti treatment merchant - <a href="https://amenahealthp.com/">uti treatment lump</a> treatment for uti stagger
Iyelau
prostatitis pills guest - <a href="https://xprosttreat.com/">prostatitis medications witch</a> prostatitis pills event
Nnkcci
valacyclovir stop - <a href="https://gnantiviralp.com/">valtrex pills nothing</a> valtrex pills fence
Vqnwnh
claritin right - <a href="https://clatadine.top/">loratadine medication colour</a> loratadine medication shove
Gymqhn
claritin pills introduce - <a href="https://clatadine.top/">claritin pills halt</a> loratadine medication messenger
Egonlv
dapoxetine shire - <a href="https://prilixgn.top/">dapoxetine closer</a> priligy motive
Bhvwrr
promethazine sense - <a href="https://prohnrg.com/">promethazine misery</a> promethazine lee
Sdjvro
ascorbic acid aid - <a href="https://ascxacid.com/">ascorbic acid watson</a> ascorbic acid hollow
Wsprgb
florinef pills foul - <a href="https://gastroplusp.com/prlansoprazole/">prevacid pills fork</a> prevacid pills slap
Miorqn
clarithromycin same - <a href="https://gastropls.com/ranitidineonline/">zantac presence</a> cytotec pills produce
Tdahxb
purchase bisacodyl for sale - <a href="https://gastroinfop.com/liv52/">brand liv52</a> liv52 20mg canada
Ffmfuw
aciphex 20mg sale - <a href="https://gastrointesl.com/reglanmetoclop/">reglan 10mg sale</a> purchase domperidone online cheap
Bbcxxq
bactrim 480mg over the counter - <a href="https://tobmycin.com/">tobra buy online</a> oral tobra 10mg
Cqmnfs
buy generic zovirax online - <a href="https://cerazestrel.com/">cerazette 0.075 mg cost</a> buy generic duphaston online
Wyxkij
dapagliflozin 10mg drug - <a href="https://sineqpin.com/">cheap sinequan 25mg</a> precose 50mg generic
Kzvkfb
fulvicin us - <a href="https://fulviseoful.com/">griseofulvin price</a> order gemfibrozil 300mg without prescription
Olqrkc
dimenhydrinate online - <a href="https://prasilx.com/">prasugrel 10mg sale</a> purchase actonel sale
Zjquoi
buy feldene 20 mg without prescription - <a href="https://feldexicam.com/">buy piroxicam online cheap</a> rivastigmine order online
Xyjouu
monograph 600mg over the counter - <a href="https://etodograph.com/">purchase etodolac without prescription</a> purchase pletal
Ysrlqe
purchase nootropil generic - <a href="https://nootquin.com/praziquantel/">buy biltricide generic</a> buy sinemet pills
Fmvzvt
buy hydrea generic - <a href="https://hydroydrinfo.com/pentoxifylline/">buy generic pentoxifylline online</a> robaxin 500mg drug
Jtzurk
cost norpace - <a href="https://anorpica.com/lamotrigine/">lamotrigine 200mg for sale</a> thorazine where to buy
Dwnwdi
depakote online buy - <a href="https://adepamox.com/amiodarone/">generic cordarone 200mg</a> topamax tablet
Jdmuwm
buy generic cytoxan - <a href="https://cycloxalp.com/stavudine/">buy stavudine generic</a> buy vastarel generic
Xucrii
purchase spironolactone online - <a href="https://aldantinep.com/dosulepin/">buy dosulepin online</a> revia 50mg price
Qtcwea
purchase flexeril generic - <a href="https://abflequine.com/primaquine/">order primaquine for sale</a> buy enalapril generic
Almsxr
where to buy zofran without a prescription - <a href="https://azofarininfo.com/">zofran buy online</a> order ropinirole 1mg online
Ydausd
ascorbic acid 500mg cost - <a href="https://mdacidinfo.com/prochlorperazine/">how to buy prochlorperazine</a> compro over the counter
Ebnlnt
durex gel buy online - <a href="https://xalaplinfo.com/">durex gel online order</a> latanoprost eye drops
Lorgsd
buy arava generic - <a href="https://infohealthybones.com/calciumcarbonate/">buy calcium carbonate pill</a> buy cartidin sale
Cobhey
cheap minoxidil without prescription - <a href="https://hairlossmedinfo.com/">generic rogaine</a> cost finpecia
Lrbelb
tenormin medication - <a href="https://heartmedinfox.com/sotalol/">buy sotalol paypal</a> buy coreg tablets
Obfnti
order calan pills - <a href="https://infoheartdisea.com/atenolol/">tenoretic usa</a> tenoretic online
Tzegth
order atorlip without prescription - <a href="https://infoxheartmed.com/enalapril/">enalapril pills</a> bystolic price
Nxgqbp
lasuna without prescription - <a href="https://infoherbalmz.com/himcolin/">buy himcolin generic</a> himcolin cost
Mszwod
buy gasex without prescription - <a href="https://herbalinfomez.com/">gasex drug</a> buy diabecon without prescription
Efzqtr
order noroxin for sale - <a href="https://gmenshth.com/confido/">buy generic confido</a> how to get confido without a prescription
Tuekni
order speman pills - <a href="https://spmensht.com/finasteride/">buy finasteride tablets</a> buy fincar generic
Avbhhm
buy finax tablets - <a href="https://finmenura.com/kamagra/">kamagra price</a> buy generic alfuzosin over the counter
Xoxtpx
generic hytrin - <a href="https://hymenmax.com/dapoxetine/">order dapoxetine 60mg online cheap</a> dapoxetine 90mg pills
Yhoxni
order trileptal generic - <a href="https://trileoxine.com/pirfenidone/">pirfenex drug</a> order levothyroxine pill
Ljtecp
purchase duphalac generic - <a href="https://duphalinfo.com/">lactulose ca</a> buy betahistine 16mg generic
Zyndst
buy imusporin generic - <a href="https://asimusxate.com/">imusporin drug</a> buy gloperba cheap
Nnywrj
order besifloxacin sale - <a href="https://besifxcist.com/">purchase besivance sale</a> generic sildamax
Vbkqek
buy deflazacort pills - <a href="https://lazacort.com/brimonidine/">how to get alphagan without a prescription</a> order alphagan for sale
Kuatuf
buy cheap generic neurontin - <a href="https://aneutrin.com/">gabapentin 100mg uk</a> purchase sulfasalazine for sale
Xjtdcl
order probenecid 500mg generic - <a href="https://bendoltol.com/monograph/">order etodolac 600 mg for sale</a> order carbamazepine 200mg generic
Zitlew
purchase celecoxib without prescription - <a href="https://celespas.com/flavoxate/">cheap flavoxate generic</a> oral indomethacin
Flwlax
order colospa 135mg online cheap - <a href="https://coloxia.com/">mebeverine order</a> order pletal 100mg online cheap
Jvofbe
buy voltaren 50mg pill - <a href="https://dicloltarin.com/">buy cambia no prescription</a> aspirin generic
Qqipxz
cheap rumalaya online - <a href="https://rumaxtol.com/shallaki/">purchase shallaki</a> endep where to buy
Kzngvt
pyridostigmine oral - <a href="https://mestonsx.com/azathioprine/">azathioprine 25mg tablet</a> buy imuran 25mg for sale
Yjkznb
cheap voveran generic - <a href="https://vovetosa.com/tisosorbide/">order isosorbide 20mg for sale</a> purchase nimotop generic
Fuvyhe
how to get ozobax without a prescription - <a href="https://baclion.com/nspiroxicam/">order generic piroxicam</a> purchase feldene generic
Vxejhf
buy cyproheptadine - <a href="https://periheptadn.com/aszanaflex/">tizanidine 2mg uk</a> tizanidine 2mg brand
Pjdzcc
where can i buy trihexyphenidyl - <a href="https://voltapll.com/diclofenacgel/">diclofenac gel order online</a> purchase diclofenac gel sale
Ypwfab
buy cefdinir 300 mg generic - <a href="https://omnixcin.com/aminocycline/"></a> cleocin generic
Wvxvlj
accutane 20mg pills - <a href="https://aisotane.com/">purchase accutane online</a> deltasone 40mg uk
Irtxnm
buy prednisone 5mg generic - <a href="https://apreplson.com/prednisolone/">buy omnacortil online</a> buy zovirax
Hoqjkk
acticin cheap - <a href="https://actizacs.com/">permethrin generic</a> retin price
Sqhlpz
betamethasone 20gm creams - <a href="https://betnoson.com/">cost betnovate</a> benoquin for sale online
Oitayz
order metronidazole 400mg sale - <a href="https://ametronles.com/">order metronidazole 200mg generic</a> buy cenforce sale
Xzvyab
clavulanate where to buy - <a href="https://baugipro.com/">augmentin 375mg brand</a> buy levothyroxine medication
Bncccu
cleocin uk - <a href="https://indometnp.com/">where can i buy indocin</a> buy indomethacin 50mg sale
Kbjpgt
how to get hyzaar without a prescription - <a href="https://cozartan.com/">hyzaar without prescription</a> where can i buy cephalexin
Nanlmr
order crotamiton - <a href="https://aeuracream.com/caczone/">oral aczone</a> how to get aczone without a prescription
Pzvdua
how to get modafinil without a prescription - <a href="https://sleepagil.com/phenergan/">buy phenergan online</a> buy meloset 3mg for sale
Zufrpg
bupropion brand - <a href="https://bupropsl.com/shuddhaguggulu/">shuddha guggulu price</a> buy shuddha guggulu without a prescription
Ucpoxn
capecitabine 500 mg canada - <a href="https://xelocap.com/danocrine/">buy danazol 100mg generic</a> order danocrine sale
Hirtny
order progesterone 100mg - <a href="https://apromid.com/">purchase prometrium pill</a> buy fertomid online
Ehjfql
norethindrone 5 mg brand - <a href="https://norethgep.com/lumigan/">oral lumigan</a> yasmin online buy
Cvrcih
alendronate over the counter - <a href="https://pilaxmax.com/pilex/">pilex pills</a> medroxyprogesterone 10mg over the counter
Lwewjn
buy cabergoline sale - <a href="https://adostilin.com/cabgolin/">cheap cabgolin without prescription</a> alesse cheap
Zasstv
order generic estrace 1mg - <a href="https://festrolp.com/">order estrace 1mg generic</a> buy arimidex online cheap
Iosbgo
г‚·гѓ«гѓ‡гѓЉгѓ•г‚Јгѓ«гЃЇи–¬е±ЂгЃ§иІ·гЃ€г‚‹пјџ - <a href="https://jpedpharm.com/tadalafil/">г‚·г‚ўгѓЄг‚№ гЃЉгЃ™гЃ™г‚Ѓ</a> г‚їгѓЂгѓ©гѓ•г‚Јгѓ« еЂ‹дєєијёе…Ґ гЃЉгЃ™гЃ™г‚Ѓ
Ywogsb
プレドニン どこで買える - <a href="https://jpaonlinep.com/jazithromycin/">アジスロマイシン 副作用</a> ジスロマック 値段
Meyxms
プレドニン 個人輸入 おすすめ - <a href="https://jpanfarap.com/jpadoxycycline/">ドキシサイクリン 市販 おすすめ</a> イソトレチノイン通販 安全
Obkolc
eriacta clever - <a href="https://eriagra.com/fforzestf/">forzest huge</a> forzest taste
Bixcto
buy crixivan - <a href="https://confindin.com/emulgel/">purchase emulgel online cheap</a> voltaren gel online buy
Obzyqk
valif online drug - <a href="https://avaltiva.com/tysecnidazolef/">purchase secnidazole pills</a> sinemet 10mg usa
Kcgoxx
where to buy modafinil without a prescription - <a href="https://provicef.com/cefadroxil/">cefadroxil 250mg ca</a> combivir pills
Xbuyrh
buy ivermectin 3mg - <a href="https://ivercand.com/">ivermectin 6mg online</a> tegretol oral
Pwuflm
generic promethazine 25mg - <a href="https://prometacin.com/jilincomycin/">cost lincocin</a> lincocin 500mg cost