2

Gspread の get_all_values() に問題があります

import json
import gspread
from oauth2client.client import SignedJwtAssertionCredentials
from gmail_variables import *

json_key = json.load(open('key7367.json'))
scope = ['https://spreadsheets.google.com/feeds']

credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope)

gc = gspread.authorize(credentials)


wks = gc.open_by_url('https://docs.google.com/a/test.com/spreadsheets/d/1-cAg..sLt5Ho/edit?usp=sharing')

recipients = wks.get_all_values()

Google スプレッドシートから取得する電子メール プログラムを作成しようとしています。実行しようとすると; エラーが発生します。

'Spreadsheet' object has no attribute 'get_all_values'

どんな助けでも大歓迎です。

4

2 に答える 2

1

ワークブックを開いているだけで、get_all_values を取得するワークシートを指定していません。get_worksheet()メソッドを呼び出す必要があります。試す:

wks = gc.open_by_url('https://docs.google.com/a/test.com/spreadsheets/d/1-cAg..sLt5Ho/edit?usp=sharing').get_worksheet(0)

recipients = wks.get_all_values()

「0」はワークシートのインデックスです (0 はワークブックの最初のワークシートです)。

于 2015-07-15T05:59:46.567 に答える