Python - Date and Time: AttributeError: 'module' object has no attribute 'month'

后端 未结 5 1118
醉话见心
醉话见心 2021-01-20 21:41

This is my calendar code in Python and I have saved it to my folder as calendar.py.

import calendar
a = calendar.month(2016, 3)
print (a)
print          


        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-20 22:21

    Had the same challenge. If the issue is not with a similar file name, please note that the prevmonth and nextmonth functions have been deprecated https://bugs.python.org/issue35406

    You can still access them using the _prevmonth and _nextmonth functions, but note that they don't check if the month is valid (kindly refer to the link posted above for details), so you may need to write your assert statement before using them

    MONTH_NUMBER = 12 # enter your month number here
    assert MONTH_NUMBER in range(0,13)
    
    # continue the rest of your code
    

提交回复
热议问题