gspread给出TypeError:尝试登录时需要字节

2024-06-28 19:59:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用Google电子表格OAuth和gspread库。我在发送凭据时遇到TypeError: expected bytes, not str异常。我怎么解决这个问题?在

import gspread
import json
from oauth2client.client import SignedJwtAssertionCredentials

json_key = json.load(open('Test for gspread-78c678a7fb15.json'))
scope = ['https://spreadsheets.google.com/feeds']
credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope)
gc = gspread.authorize(credentials)
^{pr2}$

Tags: keyimportclientjsonbytesgooglenotoauth