gpt4 book ai didi

python - 谷歌表格: updating values to multiple keys with one call

转载 作者:行者123 更新时间:2023-12-01 08:22:11 24 4
gpt4 key购买 nike

看来我一次只能用一个键更新一个文件:service.spreadsheets().values().batchUpdate(spreadsheetId=key, body=body).execute()

是否有任何技巧可以使用多个键一次调用来更新多个工作簿?

最佳答案

回答“是否有任何技巧可以使用多个键通过一次调用更新多个工作簿?”

不幸的是,在现阶段,答案是否定的。spreadsheets.values.batchUpdate的端点如下。

POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values:batchUpdate

在此端点中,包含一个电子表格ID。不幸的是,这种方法只能通过一次 API 调用请求一张电子表格。当然,可以通过一次 API 调用,使用电子表格.values.batchUpdate 对一张电子表格运行多项更新。

例如,如果 the batch requests like Drive API可以运行,spreadsheets.values.batchUpdate 可以通过一个 API 调用用于多个电子表格。但现阶段还不能使用这种方法。

解决方法

如果OP关注Sheets API的配额,这个解决方法怎么样?在此解决方法中,使用带有 Google Apps 脚本的 Web Apps。当 "Spreadsheet services"使用 Google Apps 脚本后,即使更新多个电子表格,Sheets API 的配额也不会减少。此解决方法的流程如下。

  1. 创建您想要通过 Google Apps 脚本的电子表格服务执行的脚本。
  2. 将脚本部署为 Web 应用程序。
    • 此时,您还可以通过 Web Apps 的设置,使用访问 token 来访问 Web Apps。
  3. 使用 Python 脚本(如 API)来使用网络应用。

引用文献:

关于python - 谷歌表格: updating values to multiple keys with one call,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54558169/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com