zoukankan      html  css  js  c++  java
  • calendar模块

    calendar模块是个日历模块

    1  判断是否是闰年

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

    2  指定某年某月日历

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

    3  打印返回的整年的日历

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

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

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

    5 返回工作日

    #!/urs/bin/evn python
    # -*- coding:utf-8 -*-
    import calendar
    print(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 calendar
    print(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]]
  • 相关阅读:
    Oracle 11g R2 常用配置与日志的文件位置
    DBA常用SQL之会话与等待事件
    SSH框架之Spring第三篇
    SSH框架之Spring第二篇
    SSH框架之Spring第一篇
    SSH框架之Struts2第三篇
    SSH框架之Struts2第一篇
    SSH框架之Struts2第二篇
    SSH框架之Hibernate第四篇
    SSH框架之Hibernate第三篇
  • 原文地址:https://www.cnblogs.com/zqxqx/p/9236427.html
Copyright © 2011-2022 走看看