首页 > 解决方案 > 在 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)

谢谢!

标签: pythongspread

解决方案


推荐阅读