Google Sheets-Python访问超时
我正在尝试从谷歌电子表格读写。我在网上找到了这个教程,它似乎对很多人都有用: 到目前为止我所做的:Google Sheets-Python访问超时,python,json,google-sheets-api,Python,Json,Google Sheets Api,我正在尝试从谷歌电子表格读写。我在网上找到了这个教程,它似乎对很多人都有用: 到目前为止我所做的: 根据指南创建凭据并下载.json文件 与客户端电子邮件共享立法者电子表格的副本(现在在我的google Drive中) 我在分享后收到一封电子邮件,邮件未送达,因为找不到服务帐户域 我采纳了这个准则 import gspread from oauth2client.service_account import ServiceAccountCredentials scope = ['https
- 根据指南创建凭据并下载.json文件
- 与客户端电子邮件共享立法者电子表格的副本(现在在我的google Drive中)
- 我在分享后收到一封电子邮件,邮件未送达,因为找不到服务帐户域
- 我采纳了这个准则
import gspread from oauth2client.service_account import ServiceAccountCredentials scope = ['https://spreadsheets.google.com/feeds'] creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope) client = gspread.authorize(creds) sheet = client.open("Copy of Legislators 2017", scope) list_of_hashes = sheet.get_all_records() print(list_of_hashes)
范围
部分总是不同的。有人能给我解释一下需要在那里插入什么吗?
有人对此有经验吗?感谢您的帮助:)确保您的OAuthclientID有效,并且您已经在Google开发控制台中启用了Sheets API 然后,尝试改用Sheetsv4作用域。我记得在使用v3的作用域时遇到了一些错误。希望这能帮助你:
import gspread
from oauth2client.service_account import ServiceAccountCredentials
import pprint
scope = ['https://www.googleapis.com/auth/spreadsheets']
creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
client = gspread.authorize(creds)
sheet = client.open('NAME_OF_GOOGLE_SHEET').sheet1
pp = pprint.PrettyPrinter()
# get all the records
result = sheet.get_all_records()
pp.pprint(result)
确保您的OAuthclientID有效,并且您已经在Google开发控制台中启用了Sheets API 然后,尝试改用Sheetsv4作用域。我记得在使用v3的作用域时遇到了一些错误。希望这能帮助你:
import gspread
from oauth2client.service_account import ServiceAccountCredentials
import pprint
scope = ['https://www.googleapis.com/auth/spreadsheets']
creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
client = gspread.authorize(creds)
sheet = client.open('NAME_OF_GOOGLE_SHEET').sheet1
pp = pprint.PrettyPrinter()
# get all the records
result = sheet.get_all_records()
pp.pprint(result)