最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
python如何实现万年历效果
时间:2017-05-22 编辑:简简单单 来源:一聚教程网
本文实例为大家分享了python实现万年历的具体代码,供大家参考,具体内容如下
代码如下 | 复制代码 |
#coding:utf-8 defleap_year(year):#判断平瑞年 ifyear%4==0andyear%100!=0oryear%400==0: returnTrue else: returnFalse defgetMonthDays(year,month):#得到每个年份每月的天数 days=31 ifmonth==2: ifleap_year(year): days=29 else: days=28 elifmonth==4ormonth==6ormonth==9ormonth==11: days=30 returndays
defgetTotalDays(year,month):#计算星期 totalDays=0 foriinrange(1,year): ifleap_year(i): totalDays+=366 else: totalDays+=365 foriinrange(1,month): totalDays+=getMonthDays(year,i) returntotalDays year=input("输入年份:") month=input("请输入月:") iCount=0 print"日\t一\t二\t三\t四\t五\t六" i=1 foriinrange((getTotalDays(year,month)%7)+1): print'\t', iCount+=1 foriinrange(1,getMonthDays(year,month)+1): printi,'\t', iCount+=1 ifiCount%7==0: print'' |
运行效果:
以上就是本文的全部内容,希望对大家的学习有所帮助,
-
下一个: 正则表达式对qq号码校验
相关文章
- VBS 批量Ping的项目讲解 09-19
- 如何封装一个Ajax函数介绍 09-16
- ASP实现加法验证码方法 09-16
- ASP错误捕获的几种常规处理方法介绍 09-16
- ajax实现城市三级联动的代码介绍 09-16
- asp中获取日期为星期几的技巧 09-14