該程序嚴格設置在2014年。但是,我想知道我是否正朝着正確的方向前進。這是我到目前爲止有:如何計算一週中的某一天提供的日期和月份
def day(d,m): # Function for determining day name for a given date.
"""Where m is an integer from 1 through 12 expressing a month, and d is an integer from
1 through 31 expressing the day-part of a date in 2014."""
day = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']
weekday = (d + (2.6*m - 0.2) -2*20 + 2014 + (2014//4) + (20//4))
return day[weekday]
'DateTime'立即爲您解決這個問題。只需檢查文檔。如果你在日期中給出構造;你可以使用格式化程序來輸出'day'。不要重新發明輪子;) – 2014-02-16 22:20:16