[英]During handling of the above exception, another exception occurred: & google sheets not found
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ['https://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name('Credentials.json',scope)
result = gspread.authorize(credentials)
res = result.open('A').sheet1
print(res.get_all_records())
Traceback (most recent call last):
File "C:\Users\Umair\PycharmProjects\Web\venv\lib\site-packages\gspread\client.py", line 123, in open
self.list_spreadsheet_files()
File "C:\Users\Umair\PycharmProjects\Web\venv\lib\site-packages\gspread\utils.py", line 37, in finditem
return next((item for item in seq if func(item)))
StopIteration
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/Umair/PycharmProjects/Web/PhytonRandom.py", line 6, in <module>
res = result.open('A').sheet1
File "C:\Users\Umair\PycharmProjects\Web\venv\lib\site-packages\gspread\client.py", line 131, in open
raise SpreadsheetNotFound
gspread.exceptions.SpreadsheetNotFound
From the GSpread documentation :从GSpread 文档:
open(title)
Raises: gspread.SpreadsheetNotFound – if no spreadsheet with specified title is found.引发: gspread.SpreadsheetNotFound – 如果没有找到具有指定标题的电子表格。
The Sheet title specified (in your code, A
) has to exist in your account.指定的工作表标题(在您的代码中, A
)必须存在于您的帐户中。 Furthermore, the sheet with the name Sheet1
must also be present so it can also be accessed by your line of code res = result.open('A').sheet1
此外,名称为Sheet1
的工作表也必须存在,以便您的代码行也可以访问它res = result.open('A').sheet1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.