Python 如何破译终端所说的内容,并可能提供如何使代码工作的解决方案?

Python 如何破译终端所说的内容,并可能提供如何使代码工作的解决方案?,python,terminal,Python,Terminal,我对python编码和一般的编码都是全新的。我正在做一个项目,从谷歌表单中获取信息,并将其显示在终端上。它似乎不起作用,但作为一个初学者(这是我的第一个项目),我不知道该做什么。我使用GoogleAPI获取凭据。以下是我编写的代码: import gspread from oauth2client.service_account import ServiceAccountCredentials scope = ['https://spreadsheets.google.com/feeds']

我对python编码和一般的编码都是全新的。我正在做一个项目,从谷歌表单中获取信息,并将其显示在终端上。它似乎不起作用,但作为一个初学者(这是我的第一个项目),我不知道该做什么。我使用GoogleAPI获取凭据。以下是我编写的代码:

import gspread
from oauth2client.service_account import ServiceAccountCredentials


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

sheet = client.open('python test').sheet1

options = sheet.get_all_records()
print(options)
这是终端中的结果:

Traceback (most recent call last):
   File "/Users/jordanmaggin/Desktop/python/sheets.py", line 9, in <module>
    sheet = client.open('python test').sheet1   File "/Users/jordan/opt/anaconda3/lib/python3.7/site-packages/gspread/client.py", line 123, in open
    self.list_spreadsheet_files()
   File "/Users/jordanmaggin/opt/anaconda3/lib/python3.7/site-packages/gspread/client.py", line 96, in list_spreadsheet_files
    res = self.request('get', url, params=params).json()
   File "/Users/jordan/opt/anaconda3/lib/python3.7/site-packages/gspread/client.py", line 79, in request
    raise APIError(response) gspread.exceptions.APIError: {'errors': [{'domain': 'global', 'reason': 'insufficientPermissions', 'message': 'Insufficient Permission: Request had insufficient authentication scopes.'}], 'code': 403, 'message': 'Insufficient Permission: Request had insufficient authentication scopes.'}
回溯(最近一次呼叫最后一次):
文件“/Users/jordanmaggin/Desktop/python/sheets.py”,第9行,在
sheet=client.open('python test').sheet1文件“/Users/jordan/opt/anaconda3/lib/python3.7/site packages/gspread/client.py”,第123行,打开
self.list\u电子表格\u文件()
文件“/Users/jordanmaggin/opt/anaconda3/lib/python3.7/site packages/gspread/client.py”,第96行,在列表电子表格文件中
res=self.request('get',url,params=params).json()
文件“/Users/jordan/opt/anaconda3/lib/python3.7/site packages/gspread/client.py”,第79行,在请求中
raise APIRROR(response)gspread.exceptions.APIRROR:{'errors':[{'domain':'global','reason':'infecificientpermissions','message':'infecificientpermissions:请求的身份验证作用域不足。}],'code':403,'message':'infecificimited permissions:请求的身份验证作用域不足。}
以下是我正在使用的教程:

这似乎是一个身份验证问题。您应该验证此用户是否具有打开此文件的权限

谢谢你这么快回答。请解释如何验证用户是否具有打开此文件的正确权限。最简单的方法是在浏览器中与该用户登录,然后尝试在该链接中打开该文件。您应该会看到权限问题。添加
https://www.googleapis.com/auth/drive.readonly
like
scope=['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive.readonly“]
?但是
https://spreadsheets.google.com/feeds
将被弃用。因此,在本例中,如何修改为
scope=['https://www.googleapis.com/auth/spreadsheets', 'https://www.googleapis.com/auth/drive.readonly“]
?似乎就是这样。非常感谢你