我为python 3.4和python 2.7下载了带pip和pip3的gspread。当使用python(2.7.6)运行下面的代码时,它运行没有问题,但是当在python3(3.4.3)上运行它时会抛出此错误,请帮助,我不知道该怎么做。我尝试升级请求,但没有任何区别。
Traceback (most recent call last):
File "test.py", line 11, in <module>
sheet = client.open('Test').sheet1
File "/home/marbj634/.local/lib/python3.4/site-packages/gspread/client.py", line 82, in open
feed = self.get_spreadsheets_feed()
File "/home/marbj634/.local/lib/python3.4/site-packages/gspread/client.py", line 155, in get_spreadsheets_feed
r = self.session.get(url)
File "/home/marbj634/.local/lib/python3.4/site-packages/gspread/httpsession.py", line 73, in get
return self.request('GET', url, params=params, **kwargs)
File "/home/marbj634/.local/lib/python3.4/site-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/python3/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
import pprint
scope = ['https://spreadsheets.google.com/feeds']
creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
client = gspread.authorize(creds)
pp = pprint.PrettyPrinter()
sheet = client.open('Test').sheet1
values = sheet.get_all_values()
pp.pprint(values)
答案 0 :(得分:0)
哦我尝试升级请求但需要升级请求。简单的错误,工作没有,所以解决了!