我正在编写一个python(ver3)脚本来使用gspread访问谷歌文档。
1) 导入gspread2) 从oauth2client.service_account导入ServiceAccountCredentials3) 范围=['https://spreadsheets.google.com/feeds']4) credentials=ServiceAccountCredentials.from_json_keyfile_name(r’/path/to/jason/file/xxxxxx.json’,范围)5) gc=gspread.authorize(凭据)6) wks=gc.open(“测试”).sheet1
测试是一个谷歌工作表它似乎已打开并读取良好,但如果我尝试从Office excel文件读取,则会出现错误。它们的外观如下:![在此处输入图像描述](https://i.sstatic.net/fQ5P7.png)
test和mtg所在的文件夹与我在json文件中收到的电子邮件共享。这两个文件也与该电子邮件共享。
尝试:
wks=gc.open(“mtg.xls”).sheet1
和
wks=gc.open(“mtg.xls”)<第一张表的名称>
和
wks=gc.open(“mtg”)<第一张表的名称>
错误:
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/gspread/client.py“,152号线,处于开放状态引发电子表格未找到gspread.exceptions。未找到电子表格