defisLUN(year):if year%100==0:if year%400==0:return 1
else:if year%4==0:return 1
return0defdijitian(YEAR,Month,day):
ret=0
ping=[31,28,31,30,31,30,31,31,30,31,30,31]
lun=[31,29,31,30,31,30,31,31,30,31,30,31]ifisLUN(YEAR):for i in range(Month-1):
ret=ret+lun[i]else:for i in range(Month-1):
ret=ret+ping[i]return ret+day;defjiejiari(YEAR,Month,day):
S=(YEAR+(YEAR-1)//4-(YEAR-1)//100+(YEAR-1)//400)%7days=(dijitian(YEAR,Month,day)+S-1)%7
#returndaysif days==0 or days==6:return 1
else:return 0
返回 0代表周末 1代表周一和周五
使用 return days时 0->周末 1->周一
def isLUN(year): if year%100==0: if year%400==0: return 1 else: if year%4==0: return 1 return 0
def dijitian(YEAR,Month,day): ret=0 ping=[31,28,31,30,31,30,31,31,30,31,30,31] lun=[31,29,31,30,31,30,31,31,30,31,30,31] if isLUN(YEAR): for i in range(Month-1): ret=ret+lun[i] else: for i in range(Month-1): ret=ret+ping[i] return ret+day;
def jiejiari(YEAR,Month,day): S=(YEAR+(YEAR-1)//4-(YEAR-1)//100+(YEAR-1)//400)%7 days=(dijitian(YEAR,Month,day)+S-1)%7 return days if days==0 or days==6: return 1 else : return 0