python - xlwt 错误消息 IOError : [Errno 13] Permission denied: 'python_spreadsheet.xls'

标签 python python-2.7 xlwt

import xlwt

book = xlwt.Workbook(encoding="utf-8")
sheet1 = book.add_sheet("Python Sheet 1") 
sheet2 = book.add_sheet("Python Sheet 2") 
sheet3 = book.add_sheet("Python Sheet 3")
sheet1.write(0, 0, "This is the First Cell of the First Sheet") 
sheet2.write(0, 0, "This is the First Cell of the Second Sheet") 
sheet3.write(0, 0, "This is the First Cell of the Third Sheet") 
sheet2.write(1, 10, "This is written to the Second Sheet") 
sheet3.write(0, 2, "This is part of a list of information in the Third Sheet") 
sheet3.write(1, 2, "This is part of a list of information in the Third Sheet") 

book.save("python_spreadsheet.xls")

有谁知道我为什么会收到这个错误?我真的只是从包的演示网站上复制了这段代码,但我得到了这个错误。

IOError: [Errno 13] Permission denied: 'python_spreadsheet.xls'

最佳答案

在 Windows 上,如果文件在 Excel 中打开,您会收到该错误。

在 Linux 上,如果您没有写入输出目录或文件的权限,您将收到该错误。

关于python - xlwt 错误消息 IOError : [Errno 13] Permission denied: 'python_spreadsheet.xls' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30781894/

相关文章:

python - 如何从kml文件中获取所有坐标?

python - 如何在 Bokeh 中将 "group by"数据帧绘制为条形图

正则表达式仅匹配 10 或 12 位数字

python - 使用 python2.7 和 nltk 将代词替换为其先行词

python - 复制的excel单元格值在另一个打印时不采用百分比值

python - 使用 xlwt 仅将单元格值的文本写入 xls 文件

python - 在 Python 中读取 .mat 文件

python - 有没有更好的方法从 Python 模块导入变量?

python - sympysolve() 无法找到解决方案

python - Xlrd、xlwt 和 xlutils : how do they work together