datetime error in Python
Posted: Thu Oct 27, 2016 10:17 am
I had an error when I execute the following code:
format = '%m/%d/%y/%H:%M:%S'
t = datetime.strptime(result[a][b], format) ### result [a][b] contains a string
I use %y because the year contain only last two digits. This code works perfectly for all cases except those in which day and month are the same. For eg: 02/11/11 gives an error but 11/11/16 doesn't. Does anyone know why this happens?
format = '%m/%d/%y/%H:%M:%S'
t = datetime.strptime(result[a][b], format) ### result [a][b] contains a string
I use %y because the year contain only last two digits. This code works perfectly for all cases except those in which day and month are the same. For eg: 02/11/11 gives an error but 11/11/16 doesn't. Does anyone know why this happens?