AttributeError:模块“gspread”没有属性“service_account”

问题描述 投票:0回答:1

我正在尝试使用 gspread 库从 Colaboratory 访问电子表格,但出现属性错误

module 'gspread' has no attribute 'service_account'

我的代码是这样的:

import gspread as gs
import pandas as pd
gc = gs.service_account(filename='[link_to_the_service_account_json_file]')
sh = gc.open_by_url('[link_to_the_sheet]')
ws = sh.worksheet('[sheetname]')
df = pd.DataFrame(ws.get_all_records())
df.head()

我做错了什么?

python google-colaboratory gspread
1个回答
1
投票

service_account()
是在 3.6 版本中添加的,我使用的是 3.4.2

https://github.com/burnash/gspread/releases/tag/v3.6.0

© www.soinside.com 2019 - 2024. All rights reserved.