python - 在 pycharm 中,当我尝试访问 googlesheet 时显示以下错误。请我的代码和错误
问题描述
from oauth2client.service_account import ServiceAccountCredentials
import gspread
scope = ['https://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name('key.json', scope)
client = gspread.authorize(credentials)
worksheet = client.open("PM").sheet1
res = worksheet.get_all_records()
print(res)
错误
Traceback (most recent call last):
File "F:\Arul Files\Python\EXE\main.py", line 10, in <module>
credentials = ServiceAccountCredentials.from_json_keyfile_name('key.json', scope)
File "F:\Arul Files\Python\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: 'key.json'
解决方案
推荐阅读
- javascript - 如何按日期属性捆绑数组中的对象
- html - 如何使用带有 Vue 的 bootstrap 4 创建移动导航栏?
- python - 在 3D 散点图中注释单词
- r - 设置顶点名称
- javascript - 如何获得 Telerik/Kendo 的 DropDownListFor 的 SelectedIndex?
- c# - Visual Studio 不会在项目和 NuGet 引用之间切换而不重新启动
- python - Pytorch:标准化图像数据集
- c# - 从 Asp.Net API 返回 XML 数据
- java - java - 如何在java中读取多行文本,行间有空格
- content-security-policy - 包含哈希时出现内容安全策略错误