month name to month number and vice versa in python

后端 未结 12 1180
情书的邮戳
情书的邮戳 2020-11-29 20:13

I am trying to create a function that can convert a month number to an abbreviated month name or an abbreviated month name to a month number. I thought this might be a commo

12条回答
  •  一整个雨季
    2020-11-29 20:40

    To get the full calendar name from the month number, you can use calendar.month_name. Please see the documentation for more details: https://docs.python.org/2/library/calendar.html

    month_no = 1
    month = calendar.month_name[month_no]
    
    # month provides "January":
    print(month)
    
    
    

提交回复
热议问题