python萬年歷和月歷采用哪個模塊?
import datetime import calendar def getYM(): ''' 這是一個簡單的年月輸入方法 ''' year = raw_input('Input Year: ') month = raw_input('Input Month: ') return year, month def saveGetYM(): ''' 這是一個安全的年月輸入方法 ''' while True: try: year_month = raw_input('Input year and month (year,mont): ') year, month = year_month.split(',') year, month = int(year), int(month) if 1900<=year<=2200 and 1<=month<=12: break except: continue return year, month year,month = saveGetYM() c = calendar.Calendar(1) print '-- %d --'%year for w in c.monthdatescalendar(year,month)[:7:]: print '|'.join([d.strftime('%m-%d') for d in w])
下一篇輻射76能單機嗎