Python返回一个错误,但代码是

2024-04-23 23:27:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我编写了一个查找日历月份的小代码,但是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解释器中运行它时,它工作正常。你知道吗


Tags: the代码pyimportinput错误yearcalendar