Python datetime - setting fixed hour and minute after using strptime to get day,month,year

10/14 14:10
阅读数 0

问题:

I've successfully converted something of 26 Sep 2012 format to 26-09-2012 using:我已经成功地将26 Sep 2012格式转换为26-09-2012使用:

datetime.strptime(request.POST['sample_date'],'%d %b %Y')

However, I don't know how to set the hour and minute of something like the above to 11:59.但是,我不知道如何将上述内容的小时和分钟设置为 11:59。 Does anyone know how to do this?有谁知道如何做到这一点?

Note, this can be a future date or any random one, not just the current date.请注意,这可以是未来日期或任何随机日期,而不仅仅是当前日期。


解决方案:

参考一: https://en.stackoom.com/question/qJi3
参考二: https://stackoom.com/question/qJi3
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部