{"id":57,"date":"2009-05-01T14:19:10","date_gmt":"2009-05-01T21:19:10","guid":{"rendered":"http:\/\/www.reisun.com\/?p=57"},"modified":"2009-05-01T14:19:10","modified_gmt":"2009-05-01T21:19:10","slug":"qn-how-to-convert-month-name-to-month-number-in-python","status":"publish","type":"post","link":"https:\/\/www.reisun.com\/?p=57","title":{"rendered":"[QN] How to convert month name to month number in Python"},"content":{"rendered":"<p>For a short script I was writing I needed to convert a string representation of the month (&#8220;month name&#8221;) into a numerical value (&#8220;month number&#8221;). A quick google led to many solutions to the inverse problem, which to me seems a lot easier. Here is a quick and dirty solution that uses the calendar module.<\/p>\n<pre>import calendar<\/pre>\n<pre>list(calendar.month_name).index(month_name)<\/pre>\n<p>I chose to use the calendar module array month_name because I would rather not have to create a list of month names myself.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For a short script I was writing I needed to convert a string representation of the month (&#8220;month name&#8221;) into a numerical value (&#8220;month number&#8221;). A quick google led to many solutions to the inverse problem, which to me seems a lot easier. Here is a quick and dirty solution that uses the calendar module. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,14],"tags":[],"class_list":["post-57","post","type-post","status-publish","format-standard","hentry","category-python","category-quicknote"],"_links":{"self":[{"href":"https:\/\/www.reisun.com\/index.php?rest_route=\/wp\/v2\/posts\/57","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.reisun.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.reisun.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.reisun.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.reisun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=57"}],"version-history":[{"count":0,"href":"https:\/\/www.reisun.com\/index.php?rest_route=\/wp\/v2\/posts\/57\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.reisun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=57"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.reisun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=57"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.reisun.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=57"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}