美文网首页python整理
python模块: calendar

python模块: calendar

作者: 随风化作雨 | 来源:发表于2017-06-06 15:31 被阅读49次
    import calendar
    
    print calendar.calendar(2017)
    
    import calendar
    
    print calendar.month(2017, 6)
    
    import calendar
    
    print calendar.calendar(2017)
    
    import calendar
    
    print calendar.monthrange(2017, 7)
    
    import calendar
    
    print calendar.monthcalendar(2017, 7)
    
    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    
    import calendar
    
    while True:
        try:
            myinput = raw_input("please input year or month:")
            input_list = myinput.split(' ')
            if len(input_list)==1:
                year = int(input_list[0])
                cal = calendar.calendar(year)
                print cal
            elif len(input_list)==2:
                year = int(input_list[0])
                month = int(input_list[1])
                cal = calendar.month(year,month)
                print cal
            else:
                print "Your input is not right!"
        except (ValueError, TypeError):
            print "Your input is not right!"
    

    相关文章

      网友评论

        本文标题:python模块: calendar

        本文链接:https://www.haomeiwen.com/subject/bkagfxtx.html