国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python萬年歷實現代碼 含運行結果

2020-01-04 17:11:28
字體:
來源:轉載
供稿:網友

本文實例為大家分享了python實現萬年歷的具體代碼,供大家參考,具體內容如下

 

#coding:utf-8def leap_year(year):#判斷平瑞年  if year%4==0 and year%100!=0 or year%400==0:    return True  else:    return Falsedef getMonthDays(year,month):#得到每個年份每月的天數  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 daysdef getTotalDays(year,month):#計算星期  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 totalDaysyear=input("輸入年份:")month = input("請輸入月:")iCount = 0print "日/t一/t二/t三/t四/t五/t六"i=1for i in range((getTotalDays(year,month)%7)+1):    print '/t',    iCount+=1for i in range(1,getMonthDays(year,month)+1):    print i,'/t',    iCount +=1    if iCount%7 == 0 :      print ''

運行效果:

python,萬年歷

python,萬年歷

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 泗水县| 伊宁市| 株洲县| 沁阳市| 静宁县| 县级市| 独山县| 武安市| 泰州市| 贵港市| 黔东| 临泉县| 菏泽市| 依安县| 封丘县| 松原市| 衢州市| 湘西| 霸州市| 志丹县| 鄂托克前旗| 和龙市| 德格县| 张掖市| 西昌市| 赤壁市| 土默特左旗| 西安市| 永康市| 南通市| 彩票| 青龙| 淄博市| 辛集市| 喀喇沁旗| 柳江县| 镇安县| 邻水| 邵东县| 皋兰县| 金川县|