AttributeError:模块'calendar'没有属性'isleap'

时间:2017-08-04 05:22:41

标签: python python-3.x

import calendar
print(calendar.isleap(2016))

我的python版本是3.5.2,当我运行上面的命令时,我收到以下错误:

  

-AttributeError:模块'calendar'没有属性'isleap'

使用Ubuntu 16.04.2 LTS

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题(以及相同版本的Python)。尝试将代码(当然导入除外)放入函数中。它可能看起来像:

import calendar

def leap(year):
    return calendar.isleap(year)

print(leap(2016))