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 <module>
import calendar
File "/opt/lampp/htdocs/py/calendar.py", line 2, in <module>
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.
Do not name the file as calendar.py and there should be no calendar.py file on the same path
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With