Python error: add_sheet() must be called with Workbook

Python error: add_sheet() must be called with Workbook

我遇到一个错误:

Traceback (most recent call last):
  File "clubranking.py", line 14, in <module>
    ws_out = wb_out.add_sheet(sheet_name)
TypeError: unbound method add_sheet() must be called with Workbook instance as first argument (got unicode instance instead)

尝试运行这个python脚本时:

#import the writer
import xlwt
#import the reader
import xlrd
#open document
wb_in = xlrd.open_workbook('sussex.xlsx')
#get first sheet's name from the document
sheet_name = wb_in.sheet_names()[0]
#select sheet by name
ws_in = wb_in.sheet_by_name(sheet_name)
#init xlwt object, to be able to write data
wb_out = xlwt.Workbook
#initialise first sheet from the previously opened document, for     
writing
ws_out = wb_out.add_sheet(sheet_name)
#print the values in the second column of the first sheet
print first_sheet.col_values(1)
book = xlwt.Workbook('sussex.xlsx')
#in cell 0,0 (first cell of the first row) write "NIF"
first_sheet.write(0, 6, "NIF")
#in cell 0,0 (first cell of the first row) write "Points scored"
first_sheet.write(0, 6, "Points scored")

我不确定问题出在哪里,因为我是这个领域的初学者,但我们将不胜感激任何帮助。概述了我要实现的目标是我写的另一个问题:

您没有在此处打开工作簿。

wb_out = xlwt.Workbook

应该是这样的:

wb_out = xlwt.Workbook()

正确打开您的工作簿,问题应该已解决。