gpt4 book ai didi

google-api - gspread.exceptions.SpreadsheetNotFound

转载 作者:行者123 更新时间:2023-12-01 17:56:18 25 4
gpt4 key购买 nike

我正在编写一个 python(版本 3)脚本来使用 gspread 访问 google 文档。

  1)  import gspread
2) from oauth2client.service_account import ServiceAccountCredentials
3) scope = ['https://spreadsheets.google.com/feeds']
4) credentials = ServiceAccountCredentials.from_json_keyfile_name(r'/path/to/jason/file/xxxxxx.json',scope)
5) gc = gspread.authorize(credentials)
6) wks = gc.open("test").sheet1

test 是一个 google 工作表,它似乎可以打开并阅读良好,但如果我尝试从 Office excel 文件中读取,则会出现错误。这就是它们的内容看:enter image description here

test 和 mtg 所在的文件夹与我在 json 文件中收到的电子邮件共享。此外,这两个文件也与该电子邮件共享。

尝试过:

wks = gc.open("mtg.xls").sheet1

wks = gc.open("mtg.xls").<NameOfFirstSheet>

wks = gc.open("mtg").<NameOfFirstSheet> 

错误:

/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/gspread/client.py", line 152, in open raise SpreadsheetNotFound gspread.exceptions.SpreadsheetNotFound

最佳答案

我得到这个是因为我错过了第 4 步 here

Go to your spreadsheet and share it with a client_email from the step above. Otherwise you’ll get a SpreadsheetNotFound exception when trying to access this spreadsheet with gspread.

关于google-api - gspread.exceptions.SpreadsheetNotFound,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37602460/

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