有人可以解释为什么我会收到以下错误:
File "C:\Users\Saul Ramirez\Documents\Python Scripts\DQforecast.py", line 156, in xlsOutput
forecastSheet.write(index, i, 'asdf')
TypeError: object of type 'int' has no len()
此功能,
def xlsOutput(forecasts):
os.chdir('C:\\Users\\Saul Ramirez\\Desktop')
forecastWB = xlwt.Workbook()
forecastWB_name = 'Forecasts' + str(datetime.date.today()) + '.xls'
forecastSheet = forecastWB.add_sheet('Forecasst')
i=0
for rollRate in forecasts:
for index in rollRate:
forecastSheet.write(index, i, 'asdf')
i=i+1
forecastWB.save(forecastWB_name)