谷歌表格 API v4:
Python 快速入门展示了如何从 Google 电子表格中获取数据:
result = service.spreadsheets().values()
.get(spreadsheetId=spreadsheetId, range=rangeName).execute()
values = result.get('values', [])
请参阅https://developers.google.com/sheets/quickstart/python
现在,我已经解决了 Batch Get 的语法:
我尝试了以下方法,但“值”为空:
rangeName = ["Class Data!A2:E2","Class Data!A3:E3"]
result = service.spreadsheets().values().batchGet(
spreadsheetId=spreadsheetId, ranges=(rangeName)).execute()
for r in result['valueRanges']:
print (r.values()[0],r.values()[1])