欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python萬(wàn)年歷實(shí)現(xiàn)代碼 含運(yùn)行結(jié)果

 更新時(shí)間:2017年05月20日 11:10:20   作者:Doublekai  
這篇文章主要為大家詳細(xì)介紹了python萬(wàn)年歷實(shí)現(xiàn)代碼,含運(yùn)行結(jié)果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了python實(shí)現(xiàn)萬(wàn)年歷的具體代碼,供大家參考,具體內(nèi)容如下

#coding:utf-8
def leap_year(year):#判斷平瑞年
  if year%4==0 and year%100!=0 or year%400==0:
    return True
  else:
    return False
def getMonthDays(year,month):#得到每個(gè)年份每月的天數(shù)
  days = 31
  if month == 2 :
    if leap_year(year):
      days=29
    else:
      days=28
  elif month==4 or month==6 or month==9 or month==11:
    days=30
  return days

def getTotalDays(year,month):#計(jì)算星期
  totalDays=0
  for i in range(1,year):
    if leap_year(i):
      totalDays += 366
    else:
      totalDays += 365
  for i in range(1,month):
    totalDays +=getMonthDays(year,i)
  return totalDays
year=input("輸入年份:")
month = input("請(qǐng)輸入月:")
iCount = 0
print "日\(chéng)t一\t二\t三\t四\t五\t六"
i=1
for i in range((getTotalDays(year,month)%7)+1):
    print '\t',
    iCount+=1
for i in range(1,getMonthDays(year,month)+1):
    print i,'\t',
    iCount +=1
    if iCount%7 == 0 :
      print ''

運(yùn)行效果:

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論