python大坑:AttributeError: 'module' object has no attribute 'Workbook'

原文链接:python大坑:AttributeError: 'module' object has no attribute 'Workbook'

python一个大坑:文件名称绝对不要和导入的库名称一样

 

当文件名称和import的库一样时,会出现找不到导入库的属性

下面是示例:

导入的库是excel的读写库xlwt和xlrd

而文件名称为xlwt.py

然后程序代码为:


import xlwt , xlrd
filename = xlwt.Workbook()

​​​​​​
 

最后运行时候就会提示找不到属性