且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

strptime默认为1900

更新时间:2023-11-30 16:09:40

按照已经进行的操作解析日期,然后

Parse the date as you are already doing, and then

date= date.replace(2013)

这是使用的模块的最简单的解决方案之一.

This is one of simplest solution with the modules you are using.

想得更好,明年2月29日您可能会遇到问题.

Thinking better about it, you will probably face a problem next Feb 29.

input= 'Aug21  3:26PM'
output= datetime.datetime.strptime('2013 '+ input ,'%Y %b%d  %I:%M%p')