所以我有我的公鸡从我的教育和一些奇怪的原因,标签周完全不正确。。。在第53周之前一切正常,但出于某种原因,他们决定第54周也存在,现在我的代码崩溃了(当然)
所以我需要的是一些代码,告诉我的代码第54周实际上是第01周,第55周是第02周,第56周是第03周等等。 我的想法是,但我不确定如何继续下去:
if week >= 54:
something should happen here
def BuildTimeTable(Days):
#print(Days)
TimeTable = []
for i in range(len(Days)):
for j in range(len(Days[i])):
for k in range(len(Days[i][j])):
day = Days[i][j].get("Dag")[k]
start = Days[i][j].get("Begintijd")[k]
end = Days[i][j].get("Eindtijd")[k]
desc = Days[i][j].get("Activiteit")[k]
room = Days[i][j].get("Locatie")[k]
staff = Days[i][j].get("Docent")[k]
dates = Days[i][j].get("Weken")[k]
year = "2019"
week = str(dates-1)
print(week)
print(dates)
year_week_day = year + "-" + week + "-" + str(day)
result_date = str(datetime.datetime.strptime(year_week_day, "%Y-%W-%A").date())
AddTimeTableEvent(TimeTable, day, start, end, desc, room, staff, result_date)
#print(TimeTable)
return TimeTable
我现在得到的错误是:
Traceback (most recent call last):
File "swscust2ics.py", line 219, in <module>
TimeTable = BuildTimeTable(Days)
File "swscust2ics.py", line 139, in BuildTimeTable
result_date = str(datetime.datetime.strptime(year_week_day, "%Y-%W-%A").date())
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_strptime.py", line 332, in _strptime
(data_string, format))
ValueError: time data '2019-54-maandag' does not match format '%Y-%W-%A'
目前没有回答
相关问题 更多 >
编程相关推荐