import os, sys
from xlrd import open_workbook
from xlutils.copy import copy
from xlwt import easyxf, Style
import time
rb = open_workbook('A1.xls', on_demand=True,formatting_info =True)
rs = rb.sheet_by_index(0)
wb = copy(rb)
ws = wb.get_sheet(0)
start =time.time()
g1 = dict()
for row in range(1,rs.nrows):
for cell in row:
cellContent = str(cell.value)
if cellContent not in g1.keys():
g1[cellContent]=1
else:
g1[cellContent]=g1[cellContent]+1
for cellContent in g1.keys():
print cellContent, g1[cellContent]
ws.write(row,1, cellContent)
wb.save('A2.xls')
當我運行這段代碼,我得到錯誤信息cell
對象不是可迭代 什麼可能出了錯?獲取我的輸出到另一個Excel文件
我已經重新設置了代碼的格式,但顯然它是python縮進級別的關鍵。請您確認縮進仍然正確。無論如何,我相信這是正確的,您的問題將會出現。 – Edd 2014-10-08 14:21:02
問題是與行:「對於行中的單元格:」與錯誤消息「整數對象是不可迭代的。」 – Bethogee 2014-10-08 14:28:19