python整理

python模块: calendar

2017-06-06  本文已影响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!"
上一篇下一篇

猜你喜欢

热点阅读