【发布时间】:2018-02-06 19:54:46
【问题描述】:
我正在尝试在我的项目中使用 google sheet api。我正在使用教程in this link
我收到以下错误消息:
Traceback (most recent call last):
File "spreadsheet.py", line 12, in <module>
sheet = client.open("Copy of Legislators 2017").sheet1
File "/usr/local/lib/python2.7/dist-packages/gspread/client.py", line 82, in open
feed = self.get_spreadsheets_feed()
File "/usr/local/lib/python2.7/dist-packages/gspread/client.py", line 155, in get_spreadsheets_feed
r = self.session.get(url)
File "/usr/local/lib/python2.7/dist-packages/gspread/httpsession.py", line 73, in get
return self.request('GET', url, params=params, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/gspread/httpsession.py", line 65, in request
response = func(url, data=data, params=params, headers=request_headers, files=files, json=json)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 467, in get
return self.request('GET', url, **kwargs)
TypeError: request() got an unexpected keyword argument 'json'
这是我正在使用的代码:
import gspread
from oauth2client.service_account import ServiceAccountCredentials
# use creds to create a client to interact with the Google Drive API
scope = ['https://spreadsheets.google.com/feeds']
creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
[enter link description here][1]client = gspread.authorize(creds)
# Find a workbook by name and open the first sheet
# Make sure you use the right name here.
sheet = client.open("Copy of Legislators 2017").sheet1
# Extract and print all of the values
list_of_hashes = sheet.get_all_records()
print(list_of_hashes)
我已经在 google 中搜索过这个错误,但我还没有找到关于这个错误的主题。
执行sheet = client.open("Copy of Legislators 2017").sheet1命令时出现错误
【问题讨论】:
标签: python json google-sheets-api