将python中的字符串日期转换为python中的日月份

use*_*984 2 python date

我是python的新手.我有一个格式为1/11/2012的日期,我需要转换为2012年1月11日.我需要使用给定字典的程序:month = {1:January,2:February,... etc}.如果我打印(月份,日期字符串),那么我应该得到它.非常感谢您的帮助.

eum*_*iro 11

不要重新发明轮子.你不需要字典.

>>> import datetime
>>> datetime.datetime.strptime('1/11/2012', '%m/%d/%Y').strftime('%d %B %Y')
'11 January 2012'
Run Code Online (Sandbox Code Playgroud)