这是我在Python中的日历代码,我已将它保存到我的文件夹中,作为calendar.py
。Python - 日期和时间:AttributeError:'模块'对象没有属性'month'
import calendar
a = calendar.month(2016, 3)
print (a)
print ("The Calendar :")
当我执行它,它提出了一个错误:
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'
这是怎么回事?
文件名与日历模块相同。重命名文件,然后再试一次 – Pavan
http://stackoverflow.com/questions/25040033/why-calendar-module-is-not-working-on-python-3 –