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 ("The Calendar :")
When I execute it, it raises an error :
Traceback (most recent call last):
File "calendar.py", line 1, in
import calendar
File "/opt/lampp/htdocs/py/calendar.py", line 2, in
a = calendar.month(2016, 3)
AttributeError: 'module' object has no attribute 'month'
What's going on?
解决方案
The problem is that you used the name calendar.py for your file. Use any other name, and you will be able to import the python module calendar.