这是我的代码:
def updateUserDBDates():
global userDB, currentDate, previousDate, changeInDate
index = 0
index2 = 0
userDB[1] = datetime.strptime(userDB[0], "%d-%m-%Y")
userDB[0] = datetime.strftime(datetime.today(), "%d-%m-%Y")
userDB[0] = datetime.strptime(userDB[0], "%d-%m-%Y")
saveData()
currentDate = userDB[0]
previousDate = userDB[1]
changeInDate = currentDate - previousDate
这是我收到的错误:
File "/home/nathan/Documents/project001/programFiles/Project 001.py", line 170, in updateUserDBDates
userDB[1] = datetime.strptime(userDB[0], "%d-%m-%Y")
File "/usr/lib/python2.7/_strptime.py", line 325, in _strptime
(data_string, format))
ValueError: time data '2013-09-28 00:00:00' does not match format '%d-%m-%Y'
代码不应该生成时间数据'28-09-2013'
(因此可以工作)吗?