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")
有谁知道我为什么会出现此错误?我从字面上从包的演示网站复制了这段代码,并且出现了这个错误。xlwt错误消息IOError:[Errno 13] Permission denied:'python_spreadsheet.xls'
IO错误:[错误13]许可被拒绝:“python_spreadsheet.xls”
你不必写该文件夹中的文件的权限。 尝试在'book.save()'中指定您有权写入的路径。或者检查文件是否打开。 – Vaulstein