【发布时间】:2017-03-26 11:48:45
【问题描述】:
使用 Openpyxl 和 python3.5,我尝试使用下标从 excel 工作表中获取第一行,但出现错误。
# after getting filename
# after loading worksheet
# to get the first row of the worksheet
first_row = worksheet.rows[0]
# I get
Traceback (most recent call last):
File "<pyshell#54>", line 1, in <module>
first_row = phc_th_sheet.rows[1]
TypeError: 'generator' object is not subscriptable
关于获得第一行,我也尝试过 first_row = 工作表。(行=1) # 和 first_row = worksheet.rows[:1]
没有工作。有什么建议或该功能在 openpyxl 中不可用吗? 我去过https://openpyxl.readthedocs.io/en/default/ 的文档,但我发现没有足够的帮助来索引和选择行
【问题讨论】:
-
这在文档中有介绍。
标签: python excel indexing openpyxl