我创建了这个主题(删除多行文件中的行),他们建议使用包“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()
但我得到了错误:不工作
对不起重复,也许,英语不好。