如何在Gspread中加载文件?

时间:2019-05-24 18:02:12

标签: python json google-sheets gspread

当我尝试运行代码时,Gspread返回错误。它说:

Traceback (most recent call last):
  File "C:/Users/alex/.PyCharmCE2018.3/config/scratches/gspread test.py", line 6, in <module>
    creds = ServiceAccountCredentials.from_json_keyfile_name('credentials.json', scope)
  File "C:\Users\alex\PycharmProjects\opencvtest\venv\lib\site-packages\oauth2client\service_account.py", line 219, in from_json_keyfile_name
    with open(filename, 'r') as file_obj:
FileNotFoundError: [Errno 2] No such file or directory: 'credentials.json'

我尝试弄乱凭据.json,但对于Google表格来说似乎是正确的。

import gspread
from oauth2client.service_account import ServiceAccountCredentials

scope = ['https://www.googleapis.com/auth/drive']

creds = ServiceAccountCredentials.from_json_keyfile_name('credentials.json', scope)

client = gspread.authorize(creds)

sheet = client.open("RFID-2019-2020-Attendance").sheet1

print(sheet.row_values())

任何帮助将不胜感激。

0 个答案:

没有答案