`datetime.strftime` and `datetime.strptime` interprete %Y differently
问题 I use a statement as shown below to create a datetime object from a string: t = datetime.strptime("0023-10-10", "%Y-%m-%d") Later, somewhere in my code uses the t object and invoke the strftime method with the same format string: t.strftime("%Y-%m-%d") This causes a ValueError: year=23 is before 1900; the datetime strftime() methods require year >= 1900 . It seems that the validation of the %Y input is different in this two similar methods. So I have to do the following to make sure I don't