[英]Python error when trying to save a new file: IndexError: list index out of range
I am getting the above error when trying to create a new workbook with the following commands: 尝试使用以下命令创建新工作簿时出现上述错误:
import xlwt
workbook = xlwt.Workbook()
workbook.save(‘my_file.xls’)
I am new to Python and following a guide but I can't find what this error means 我是Python的新手,并按照指南进行操作,但是我找不到此错误的含义
This works for me. 这对我有用。 I think your workbook needs to be setup with a sheet to be valid.
我认为您的工作簿需要设置一张工作表才能有效。
import xlwt
workbook = xlwt.Workbook()
workbook.add_sheet("Sheet")
workbook.save("myfile.xlsm")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.