我正在嘗試打印出一些給定的月份和年份的日曆的代碼。 我的代碼如下所示:TypeError:int()參數必須是一個字符串,類似字節的對象或數字,而不是'NoneType'
#!/usr/bin/python3
"""import calender"""
import calendar
import datetime
""" begin function """
def get_the_first_day_of_the_week(month, year):
day_of_week = datetime.date(year, month, 1).weekday()
return
def print_out_calender(months, years):
this_month = int(months)
this_year = int(years)
new = get_the_first_day_of_the_week(this_month, this_year)
new = int(new)
calendar.setfirstweekday(new)
calendar.monthcalendar(this_month, this_year)
return
print_out_calender(12, 2017)
我希望它打印出最新的矩陣,但我得到這樣的錯誤: 回溯(最近通話最後一個):
File "./practice12.py", line 25, in <module>
print_out_calender(12, 2017)
File "./practice12.py", line 19, in print_out_calender
new = int(new)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
我新到python和編碼,所以有人可以告訴我爲什麼?
您是不是指'get_the_first_day_of_the_week'內的'return day_of_week'? –