datetime.strptime () throws 'does not match format' error

后端 未结 3 2267
无人共我
无人共我 2021-02-19 15:27

I get

time data \'19/Apr/2011:22:12:39\' does not match format \'%d/%b/%y:%H:%M:%S\'

when using datetime.strptime(\'19/Apr/2011:22:12:39\

3条回答
  •  [愿得一人]
    2021-02-19 15:36

    Try %d/%b/%Y:%H:%M:%S instead - %y right now means 11.

    You can "debug" datetime formats easily using date (on the shell and not on python, I mean, assuming you're running GNU/Linux or similar):

    date '+%d/%b/%Y:%H:%M:%S'
    05/May/2011:09:00:41
    

提交回复
热议问题