프로그램과 관련하여 문제가 있습니다. 그래서 하루의 이름을 반환하는 함수를 작성하려고합니다. (예 : 1.1.2014는 수요일입니다.) 나는 2014 년만을 엄격하게 다루고 있습니다. 내가 가질 입력은 d = 일, m = 월입니다.Python - 요일 이름을 반환하는 함수를 작성하십시오.
이것은 내가 지금까지 가지고있는 것입니다.
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."""
if 1<=m<=12:
return
elif 1<=d<=31:
return ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']
else:
return "Error"
수식이 필요한 경우 [여기] (http://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week)를 시작하십시오. [최후 심의의 방법] (http://en.wikipedia.org/wiki/Doomsday_rule)은 구현하기 어렵지 않습니다. – dawg