About 476,000 results
Open links in new tab
  1. Basic Python Programming to convert month number to month name using ...

    Jan 26, 2013 · You have to use int(date[0]) as your key in monthDict[int(date[0])] because you used integers as your dictionary keys. But your input (from the user) is a string, not integers.

  2. Python program to Get Month Name from Month Number

    Apr 22, 2023 · Given a datetime object or month number, the task is to write a Python program to get the corresponding month name from it. Examples: Explanation : 4th Month is April. Explanation : 1st Month is January. In this, we use strftime () which converts date object to a string using a format, and by providing %B, it’s enforced to just return a Month Name.

  3. Converting month numbers to month name using a dictionary in Python

    Jan 1, 2018 · I'm trying to convert an array of numbers (1-12) to the corresponding Month (January-December), however I have to use a dictionary. I have my months in the form of an array and I get an error for either "TypeError: only length-1 arrays can be converted to Python scalars" or "TypeError: 'dict' object is not callable"

  4. python - How to map month name to month number and vice …

    Using calendar module: Number-to-Abbr calendar.month_abbr[month_number] Abbr-to-Number list(calendar.month_abbr).index(month_abbr)

  5. Solved: Top 16 Methods to Map Month Names and Numbers in

    Dec 5, 2024 · Are you looking for ways to convert a month number to its abbreviated or full name? Or vice versa? This guide covers 16 practical and efficient methods to achieve this in Python. Whether you’re working with calendar, datetime, or custom logic, you’ll find solutions tailored to your needs. Solution 1: Using strptime from the time Module.

  6. Mapping Month Name to Month Number and Vice Versa in Python 3

    In Python, you can easily map month names to month numbers and vice versa using dictionaries. By creating a dictionary with month names as keys and month numbers as values, you can retrieve the corresponding month number for a given month name, or vice versa.

  7. Converting month names and numbers in Python: A …

    In this article, we have explored several methods to convert the month name to a month number and the month number to a month name in Python. We have seen how to use the calendar and datetime modules to map month names to month numbers and vice versa.

  8. A python dictionary of month number and month name · GitHub

    Apr 16, 2019 · months = {'01': 'Январь', '02': 'Февраль', '03': 'Март', '04': 'Апрель', '05': 'Май', '06': 'Июнь', '07': 'Июль', '08': 'Август', '09': 'Сентябрь', '10': 'Октябрь', '11': 'Ноябрь', '12': 'Декабрь'}

  9. Mastering the Art of Month Name Conversions in Python

    When you need to convert a month number to a month name in Python, you can use the strftime() method in the datetime module. With this technique, you have a choice of displaying a full or short name of the month.

  10. Python Tutorial: How to Convert Numbers to Months in Python?

    Oct 21, 2024 · In this tutorial, we explored three different methods to convert numbers to month names in Python: using a list, a dictionary, and the built-in calendar module.

  11. Some results have been removed
Refresh