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]]
  • 相关阅读:
    我最讨厌画图,这辈子我都不想再画图
    bzoj1218[HNOI2003]激光炸弹
    bzoj1196[HNOI2006]公路修建问题
    bzoj1588[HNOI2002]营业额统计
    bzoj2039[2009国家集训队]employ人员雇佣
    bzoj3874[Ahoi2014]宅男计划
    bzoj2282[Sdoi2011]消防
    bzoj1798[Ahoi2009]Seq 维护序列seq
    bzoj4003[JLOI2015]城池攻占
    bzoj2809[Apio2012]dispatching
  • 原文地址:https://www.cnblogs.com/zqxqx/p/9236427.html
Copyright © 2011-2022 走看看