对于Servi访问的gpread凭据,python中的文件位置应该是什么ceAccountCredentials.from_json_keyfile_nam

2024-06-28 16:00:47 发布

您现在位置:Python中文网/ 问答频道 /正文

导入gspread 来自oauth2client.service_帐户导入ServiceAccountCredentials

使用creds创建一个与googledriveapi交互的客户端

scope = ['https://spreadsheets.google.com/feeds'] creds = ServiceAccountCredentials.from_json_keyfile_name('PythonGspread-c6fb2247fb25.json', scope) client = gspread.authorize(creds)

按名称查找工作簿并打开第一张工作表

sheet = client.open("Python").sheet1

一定要在这里用正确的名字

提取并打印所有值

list_of_hashes = sheet.get_all_records() '结果=工作表单元格(2,1).值' print(list_of_hashes) print("\n")print(result) input("Press enter to exit ;)")


Tags: ofclientjson客户端service帐户listsheet
2条回答

尝试将范围更改为:

scope = ['https://spreadsheets.google.com/feeds',
     'https://www.googleapis.com/auth/drive']

我解决了上面的问题。在

新问题正在

gspread.exceptions.APIError: {"error": {"errors": [{"domain": "global","reason": "insufficientPermissions","message": "Insufficient Permission"}],"code": 403,"message": "Insufficient Permission" }}

我已经分享了电子表格与电子邮件提供的电子邮件在凭证。在

相关问题 更多 >