瀏覽單個文章
d9423196
New Member
 

加入日期: Jan 2008
文章: 7
python 年度版

代碼:


import calendar
year_x = raw_input(">>> Input year :")

for month in range(1, 13):

    c = calendar.monthcalendar(int(year_x), month)
    first_week = c[0]
    second_week = c[1]
    third_week = c[2]

    if first_week[calendar.TUESDAY]:
        meeting_date = second_week[calendar.TUESDAY]
    else:
        meeting_date = third_week[calendar.TUESDAY]

    print '%s/%2s/%2s' % (year_x,month, meeting_date)
    



這份介紹說得很清楚 也從這邊改來的
http://pymotw.com/2/calendar/
     
      
舊 2015-05-23, 12:11 PM #11
回應時引用此文章
d9423196離線中