Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么我会出错;gspread.exceptions.novalidurlkeyfind;关于python?_Python_Gspread - Fatal编程技术网

为什么我会出错;gspread.exceptions.novalidurlkeyfind;关于python?

为什么我会出错;gspread.exceptions.novalidurlkeyfind;关于python?,python,gspread,Python,Gspread,我是pyhon的新手,现在正在尝试使用google drive API 我已经为这个项目启用了GoogleSheet和GoogleDriveAPI访问。这是我的密码 import gspread from oauth2client.service_account import ServiceAccountCredentials scope = [ 'https://spreadsheets.google.com/feeds', 'https://www.googleapis.c

我是pyhon的新手,现在正在尝试使用google drive API

我已经为这个项目启用了GoogleSheet和GoogleDriveAPI访问。这是我的密码

import gspread
from oauth2client.service_account import ServiceAccountCredentials

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

json_file_name = '/Users/kimjongyool/Desktop/upbeat-polygon-292119-fd2b4fab4fa1.json'

credentials = ServiceAccountCredentials.from_json_keyfile_name(json_file_name, scope)
gc = gspread.authorize(credentials)

spreadsheet_url = 'https://docs.google.com/spreadsheets/d/1SAci5Is4tQ1uETGKcTCUmBQrFz4C7-wmj3NhsYgKAWc/edit#gid=0'
doc = gc.open_by_url('spreadsheet_url')
如果运行此操作,将收到错误消息“gspread.exceptions.NoValidUrlKeyFound "


我到处找,但仍然没有找到任何解决办法。请帮忙

这行代码中有一个输入错误:

doc = gc.open_by_url('spreadsheet_url')
变量名应不带引号字符(')。这是正确的版本:

doc = gc.open_by_url(spreadsheet_url)

很好,如果您对答案满意,请将其标记为已接受。