只有一个 Google 电子表格文档。
从右键单击下拉菜单中选择第一个 A1
单元格后,我选择:Get Link to this Cell
命令。
URL 链接现在存储在内存中,可以粘贴到任何文本编辑器中。复制的单元格的 URL 链接如下所示:
问题:如何在 Python 中使用 gspread
获取同一个单元格的链接?
最佳答案
首先,您需要生成 OAuth2 凭据: http://gspread.readthedocs.io/en/latest/oauth2.html
您需要使用 OAuth2 凭据在 Python 中创建一个新的授权对象:
gc = gspread.authorize(credentials)
然后您需要创建到工作表的连接:
# If you want to be specific, use a key (which can be extracted from
# the spreadsheet's url)
yoursheet = gc.open_by_key('0BmgG6nO_6dprdS1MN3d3MkdPa142WFRrdnRRUWl1UFE')
# Or, if you feel really lazy to extract that key, paste the entire url
yoursheet = gc.open_by_url('https://docs.google.com/spreadsheet/ccc?key=0Bm...FE&hl')
然后就可以抓取你想要的cell了
val = yoursheet.acell('B1').value
所有代码都是从 gspread Github 的基本用法中提取的,稍作调整 https://github.com/burnash/gspread
干杯!
关于python - 如何使用 gspread 获取 Google 电子表格单元格链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44610712/