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