python-2.7 - gspread 之类的 : help me get cell coordinates (not value)

标签 python-2.7 cell google-sheets gspread

通过使用 GSpread,我从谷歌电子表格返回了一系列单元格,该电子表格的所有元素如下所示:

<Cell R1C1 'Sandero'>

我知道如何从这里获取单元格值:
cell.value

但我也想单独获取地址(在本例中为 R1C1)。
如果我能以 (1,1) 格式(也许通过使用字典?)

你看我也需要地址,因为我稍后会用这些值声明一个图表。

我正在使用 Python 2.7 和最新的 Gspread 库。

任何帮助将不胜感激。

最佳答案

获取单元格坐标的最佳方法是使用单元格的实例属性 rowcol .这样您的代码可以简化为:

for cell in cell_list:
    print cell.value
    print "Row:", cell.row, "Column:", cell.col

要获得元组,只需将其括在括号中:(cell.row, cell.col) .

由于我是 gspread 的作者,我更新了 library page明确如何获取单元格的坐标。感谢您指出缺失的部分。

关于python-2.7 - gspread 之类的 : help me get cell coordinates (not value),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13949540/

相关文章:

iPhone SDK : Add UISlider and UISwitch in a table view only crash when touch slider?

python 在每个索引处对数组中的所有先前值求和

ubuntu - python无法显示模块列表

iphone - 通过模态视图呈现详细 View Controller

android: NeighboringCellInfo 总是空的!?为什么?

css - 当列中的日期是明天时,Google 表格电子邮件通知

google-apps-script - 如何将数据插入到特定行号(或第一个空行)?

xpath - 在Google电子表格中使用ImportXML提取标题

python - numpy 排序奇怪的行为

python-2.7 - 对 Tkinter bind_class 感到困惑