Set quot;publish to webquot; in Google spreadsheet using Drive python API(设置“发布到网络在 Google 电子表格中使用 Drive python API)
问题描述
我正在尝试使用 Python 版本的 Google Drive API 在 Google 文档中模拟单击发布到网络"->立即开始发布".根据我对文档的模糊理解,我相信这应该可行:
I'm trying to simulate clicking "publish to web" -> "start publishing now" in Google docs using the Python version of the Google Drive API. Based on my vague understanding of the documentation, I believe this should work:
service.revisions().update(fileId = newfile['id'],
revisionId='head', body={'published':True, 'publishAuto': True})
但是,这似乎对我的文档没有影响.
However, this appears to have no effect on my document.
我希望能够以编程方式创建一个可供全世界立即访问的 Google 电子表格.
I'd like to be able to programmatically create a Google spreadsheet that is immediately world-accessible.
推荐答案
原来上面代码片段返回的响应对象需要调用execute()
:
Turns out the response object that's returned by the code snippet above needs to call execute()
:
service.revisions().update(fileId = newfile['id'], revisionId='head',
body={'published':True, 'publishAuto': True}).execute()
这会返回一个修订对象并设置文档的发布属性.
This returns a revision object and sets the publish properties on the document.
这篇关于设置“发布到网络"在 Google 电子表格中使用 Drive python API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:设置“发布到网络"在 Google 电子表格中使用


- 如何在 python3 中将 OrderedDict 转换为常规字典 2022-01-01
- pytorch 中的自适应池是如何工作的? 2022-07-12
- 如何将一个类的函数分成多个文件? 2022-01-01
- python-m http.server 443--使用SSL? 2022-01-01
- python check_output 失败,退出状态为 1,但 Popen 适用于相同的命令 2022-01-01
- 沿轴计算直方图 2022-01-01
- 分析异常:路径不存在:dbfs:/databricks/python/lib/python3.7/site-packages/sampleFolder/data; 2022-01-01
- 使用Heroku上托管的Selenium登录Instagram时,找不到元素';用户名'; 2022-01-01
- 如何在 Python 的元组列表中对每个元组中的第一个值求和? 2022-01-01
- padding='same' 转换为 PyTorch padding=# 2022-01-01