博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
calendar模块
阅读量:4584 次
发布时间:2019-06-09

本文共 1221 字,大约阅读时间需要 4 分钟。

calendar模块是个日历模块

1  判断是否是闰年

1 #!/urs/bin/evn python2 # -*- coding:utf-8 -*-3 import calendar4 print(calendar.isleap(2000))5 6 返回结果:7 True

2  指定某年某月日历

1 #!/urs/bin/evn python2 # -*- coding:utf-8 -*-3 import calendar4 print(calendar.month(2018, 12))

3  打印返回的整年的日历

1 #!/urs/bin/evn python2 # -*- coding:utf-8 -*-3 import calendar4 print(calendar.prcal(2018, w=2, l=1, c=6))

4  返回指定年份和月份的月份第一天的工作日和月份中的天数

1 #!/urs/bin/evn python2 # -*- coding:utf-8 -*-3 import calendar4 print(calendar.monthrange(2018, 12))5 6 7 返回结果:8 (5, 31)

5 返回工作日

#!/urs/bin/evn python# -*- coding:utf-8 -*-import calendarprint(calendar.weekday(2018, 6, 27))weekday(year, month, day)    Return weekday (0-6 ~ Mon-Sun) for year (1970-...), month (1-12),    day (1-31).

6 返回一个表示一个月日历的矩阵

#!/urs/bin/evn python# -*- coding:utf-8 -*-import calendarprint(calendar.monthcalendar(2018, 6))monthdayscalendar(year, month) method of calendar.TextCalendar instance    Return a matrix representing a month's calendar.    Each row represents a week; days outside this month are zero.结果:[[0, 0, 0, 0, 1, 2, 3], [4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 0]]

 

转载于:https://www.cnblogs.com/zqxqx/p/9236427.html

你可能感兴趣的文章
java线程详解二
查看>>
maven项目导入依赖jar包并打包为可运行的jar包
查看>>
leecode第二十三题(合并K个排序链表)
查看>>
关于Eclipse的unsupported major minor version 51.0 错误
查看>>
2014年目标
查看>>
weblogic启动后 登陆控制台特别慢的问题
查看>>
Spring加载resource时classpath*:与classpath:的区别
查看>>
映射“DataAdapter.TableMappings”
查看>>
activity生命周期
查看>>
动画学习之Music图形绘制
查看>>
2019 2.15模拟赛
查看>>
基于H5 pushState实现无跳转页面刷新
查看>>
关于同余与模运算的总结
查看>>
js中top、clientTop、scrollTop、offsetTop的区别 文字详细说明版
查看>>
【转载】法线贴图Nomal mapping 原理
查看>>
prado 初步分析
查看>>
php 做守护进程1
查看>>
简单员工管理实例
查看>>
SAP 到出XLS
查看>>
HSV
查看>>