我创建了这个主题(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()
但我有个错误:不起作用
对不起,可能是重复的,还有糟糕的英语。你知道吗
你知道吗xlrd.sheet.sheet表格.cell方法返回xlrd.sheet.Cell单元格实例,表示存储在其值属性中的值的单元格。比如说表单元格(x,y)。值应该起作用。你知道吗
关于删除-不能使用xlrd修改文档,应该使用xlwt编写excel,使用XLUTIL读取、修改和编写文档。在google中有点紧张会给你一些类似于http://www.python-excel.org/
相关问题 更多 >
编程相关推荐