本文介绍了解析日期字符串和更改格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个日期字符串,格式为2010年2月15日星期一。我想将格式更改为15/02/2010。我该怎么做?

I have a date string with the format 'Mon Feb 15 2010'. I want to change the format to '15/02/2010'. How can I do this?

推荐答案

模块可以帮助您:

datetime module could help you with that:

datetime.datetime.strptime(date_string, format1).strftime(format2)

这篇关于解析日期字符串和更改格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-05 05:16