它一直说“语法错误”。import datetimeimport calendardef findDay(date): born = datetime.datetime.strptime(date, %d %m %y) day = born.weekday() return (calendar.day_name[day])date = '01 01 1989'print(findDay(date))cmd中显示错误
1 回答
小怪兽爱吃肉
TA贡献1852条经验 获得超1个赞
用双引号引起%d...来并将 %y 设置为 %Y:
import datetime
import calendar
def findDay(date):
born = datetime.datetime.strptime(date, "%d %m %Y")
day = born.weekday()
return (calendar.day_name[day])
date = '01 01 1989'
print(findDay(date))
添加回答
举报
0/150
提交
取消