我正在构建一个 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)
上面的代码不起作用。有什么办法可以做到这一点?
最佳答案
wks.share('', perm_type='任何人', 角色='读者')
拥有链接的所有人的阅读权限。引用 https://gspread.readthedocs.io/en/latest/api.html#gspread.models.Spreadsheet.share
关于python - 使用共享链接访问谷歌电子表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40717774/