【问题标题】:Accessing google spreadsheet using shared link使用共享链接访问谷歌电子表格
【发布时间】:2016-11-21 10:19:40
【问题描述】:

我正在构建一个 python 应用程序,用户可以在其中提供“任何人都可以编辑”链接到他们的电子表格,并且可以从那里读取数据。我正在使用 python 的 gspread 模块,但它会引发 SpreadSheetNotFound 错误。

import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('myauth.json', scope)
gc = gspread.authorize(credentials)
wks = gc.open_by_url(urls_given_by_user_having_edit_permission)

以上代码不工作。有什么方法可以实现吗?

【问题讨论】:

标签: python google-sheets gspread


【解决方案1】:

wks.share('', perm_type='anyone', role='reader')

所有拥有链接的人的阅读权限。参考https://gspread.readthedocs.io/en/latest/api.html#gspread.models.Spreadsheet.share

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-27
    • 1970-01-01
    • 1970-01-01
    • 2015-09-12
    相关资源
    最近更新 更多