【发布时间】:2014-06-02 11:17:20
【问题描述】:
给定一个具有以下布局的 Excel 工作表:
A | B
1 Name of First Column | Name of Second Column
2 Value in First Column| Value in Second Column
xlrd 肯定有一种奇怪的索引方式。首先,一些设置...
import xlrd
f = open("example.xlsx")
wb = xlrd.open_workbook(file_contents=f.read())
sh = wb.sheet_by_index(0)
让我们看看使用row_values的第一行是什么
print sh.row_values(0, start_colx=0, end_colx=1)
结果?
[u'Name of First Column']
出了什么问题? row_values 的第一个未标记参数是 rowx。 "'rowx' is a row index, counting from zero" 还有两个colx? "'colx' is a column index, counting from zero."
你可能会想,colx 都应该从零开始计数。如果我在end_colx 中指定,我想在1 列结束,我的意思是第二列,从零开始计数。
【问题讨论】: