python - 在 Collab 中自动验证 gspread
问题描述
我目前有一个脚本可以读取 Google Sheet URL,并转换为数据框。要访问此文件,我需要在每次运行脚本时进行身份验证。有没有另一种方法,这意味着我只需要做一次?
from google.colab import auth
auth.authenticate_user()
import gspread
from oauth2client.client import GoogleCredentials
gc = gspread.authorize(GoogleCredentials.get_application_default())
import pandas as pd
import matplotlib.pyplot as plt
wb = gc.open_by_url('...')
sheet = wb.worksheet('Sheet1')
data = sheet.get_all_values()
df = pd.DataFrame(data)
谢谢!
解决方案
推荐阅读
- python - 如何在单击我的应用程序定义的扩展程序时打开我的 python 应用程序?
- c - 为什么返回 void 的函数不保存值?
- azure - 在 ADB2C 无密码身份验证中跳过第一页
- docker - 如何在 Docker 容器之外执行部分 Jenkins 管道阶段?
- javascript - 从android上的html网站获取文件路径
- amazon-web-services - 如何使用 CloudFormation 设置 EC2 实例连接?
- if-statement - 使用日期和空白单元格的多个 IF 语句
- xml - 在“colspec”元素中创建@colwidth 属性和值
- python - Python 包 bar-chart-race 0.1.0:无法将分隔符千位更改为点
- c# - 如何更新我的游戏内计时器,使其仅在达到 60 秒(即 34 而不是 00:34)时才开始添加分钟计数器?