【发布时间】:2017-08-23 06:16:37
【问题描述】:
我正在尝试制作一个代码,可以打印出带有给定月份和年份的日历。 我的代码如下所示:
#!/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)
我希望它打印出日期矩阵,但我收到如下错误: Traceback(最近一次调用最后一次):
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 和编码新手,谁能告诉我为什么?
【问题讨论】:
-
你的意思是
return day_of_week在get_the_first_day_of_the_week里面吗?
标签: python python-3.x