Python datetime.strptime issue -


i trying parse date time string datetime type, here code:

import datetime  print datetime.datetime.strptime('01/01/2002 00:00:00', "%d/%m/%y %h:%m:%s") 

however, i've got error:

valueerror: time data '01/01/2002 00:00:00' not match format '%d/%m/%y %h:%m:%s'

may know how fix this?

many thanks.

your year format incorrect. should capital y:

>>> print datetime.datetime.strptime('01/01/2002 00:00:00', "%d/%m/%y %h:%m:%s") 2002-01-01 00:00:00 

i'm sure you've seen it, documentation possible values here


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

wso2esb - How to concatenate JSON array values in WSO2 ESB? -