datetime.strptime('14.07.13 15:01', "%d.%m.%Y %H:%M").date() ValueError: time data '14.07.13 15:01' does not match format '%d.%m.%Y %H:%M' What am I doing wrong?
datetime.strptime('14.07.13 15:01', "%d.%m.%Y %H:%M").date() ValueError: time data '14.07.13 15:01' does not match format '%d.%m.%Y %H:%M' What am I doing wrong?
The format for strptime() and strftime() is described on this page of the documentation . In particular, there are explanations about the %y and %Y directives (note, the register matters!)
%y is a year without a century. Year in two digits - 91, 17, 02, 05.
%Y - the year with the indication of the century - 1991, 2017, 1802, 2005.
If you have a year <1000, then you must add it with zeros so that it occupies 4 digits (0053, 0099). With two character exactly the same (05, 00, 09).
Also in version 3.6, the %G directive was added, which means a year in 4 digits (analogous to %Y ). However, this value is turbid and refers to the ISO 8601 standard. In this format, the first week of the year begins on the first Monday of that week in the year, in which there are at least 4 days. It sounds scary, but the example - January 1, 2010 is Friday, which means that according to this standard, Friday, Saturday and Sunday belong to week 53 of 2009, and the first week of 2010 begins on January 4. This all applies only to counting the numbers of the week and does not make 2010 the 2009th year. Also, this directive is not at all the same as %Y and they are not interchangeable and incompatible.
Source: https://ru.stackoverflow.com/questions/634116/
All Articles