Create a reverse dictionary using the calendar
module (which, like any module, you will need to import):
{month: index for index, month in enumerate(calendar.month_abbr) if month}
In Python versions before 2.7, due to dict comprehension syntax not being supported in the language, you would have to do
dict((month, index) for index, month in enumerate(calendar.month_abbr) if month)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…