1
我創建了這個主題(Delete lines found in file with many lines),他們建議使用包「xlrd」。我使用並與文件進行交互,但無法將單元格的內容與某些字符串進行比較。 這裏是我的代碼:找到確定的字符串並刪除單元
import xlrd
arquivo = xlrd.open_workbook('/media/IRREMOVIVEL/arquivo.xls',)
planilha = arquivo.sheet_by_index(0)
def lerPlanilha():
for i in range(planilha.ncols):
if (planilha.cell(8,9) == "2010"):
print 'it works =>'
break
else:
print 'not works'
break
lerPlanilha()
但我得到的錯誤:不工作
對不起重複,也許,和糟糕的英語。
0123也許我表達自己錯了,我想比較一個字符串與給定單元格,如果數據是相等的,它將被刪除。 – 2012-08-01 19:32:49