用Python尝试读取Google Sheets中的数据,总是报错如下
import gspread
from oauth2client.service_account import ServiceAccountCredentials
# The ID and range of a sample spreadsheet.
#SAMPLE_SPREADSHEET_ID = '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms'
#SAMPLE_RANGE_NAME = 'Class Data!A2:E'
scope = ["https://spreadsheets.google.com/feeds",'https://www.googleapis.com/auth/spreadsheets',"https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name("./creds.json", scope)
client = gspread.authorize(creds)
sheet = client.open("tutorial").sheet1 # Open the spreadhseet
data = sheet.get_all_records() # Get a list of all records
row = sheet.row_values(3) # Get a specific row
col = sheet.col_values(3) # Get a specific column
cell = sheet.cell(1,2).value # Get the value of a specific cell
insertRow = ["happy", 5, "red", "blue"]
#sheet.add_rows(insertRow, 4) # Insert the list as a row at index 4
sheet.insert_row(insertRow, 4) # Insert the list as a row at index 4
sheet.update_cell(2,2, "CHANGED") # Update one cell
numRows = sheet.row_count # Get the number of rows in the sheet
已经确保Python文件和json文件在同一个目录下,还是报错如下