如何使用python获取excel表中的行号? [英] How to get line number in excel sheet using python?
本文介绍了如何使用python获取excel表中的行号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个这样的 Excel 工作表:
I have an Excel sheet like this:
A B C D E F G
1 0 0 0
2 0 0
3 0
4
5 0 0 0 0 0 0 0
6 0 0 0
每个0"代表一些数据值,我正在读取这些值并将它们与我的原始数据进行比较,当数据匹配失败时,它返回一条消息.我想要的是返回 Excel 表的行号以及列号或特别是 CELL 位置.请帮我做这个!
And every '0' represents some data values, I am reading the values and comparing them with my original data, when the data match fails it returns a message. What I want is to return the line number of excel sheet as well as the column number or particularly the CELL location. Please help me doing this!
推荐答案
试试这个:
import xlrd
workbook = xlrd.open_workbook('book.xls')
for sheet in workbook.sheets():
for row in range(sheet.nrows):
for column in range(sheet.ncols):
print "row::::: ", row
print "column:: ", column
print "value::: ", sheet.cell(row,column).value
它将为您提供精确的row
、column
数字和cell
值
It will give you exact row
, column
numbers and cell
value
这篇关于如何使用python获取excel表中的行号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文