我编写了一个查找日历月份的小代码,但是python返回错误
# First import the calendar module
import calendar
# ask of month and year
yy = int(input("Enter year: "))
mm = int(input("Enter month: "))
# display the calendar
print(calendar.month(yy, mm))
现在,当我在kali linux中使用“python3”运行这段代码时日历.py". 它返回此错误。。你知道吗
python3 calendar.py
Enter year: 1989
Enter month: 8
Traceback (most recent call last):
File "calendar.py", line 3, in <module>
import calendar
File "/root/calendar.py", line 12, in <module>
print(calendar.month(yy, mm))
AttributeError: module 'calendar' has no attribute 'month'
当我在一些在线python解释器中运行它时,它工作正常。你知道吗
因为你把Python脚本命名为“日历.py". 它正在导入当前文件而不是实际模块。改名就行了。你知道吗
相关问题 更多 >
编程相关推荐