更具体地说,我正在遵循google的一个基本教程,试图为另一个应用程序更改单元格的背景颜色,但现在为了测试,我单独运行它。正在运行的代码是
def highlight(sheetId):
from googleapiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client as gclient, tools
SCOPES = ['https://spreadsheets.google.com/feeds','https://www.googleapis.com/auth/drive']
store = file.Storage('token.json')
creds = store.get()
if not creds or creds.invalid:
flow = gclient.flow_from_clientsecrets('credentials.json', SCOPES)
creds = tools.run_flow(flow, store)
servicebot = build('sheets', 'v4', http=creds.authorize(Http()))
reqs = {"requests": [
{
"repeatCell": {
"range": {
"sheetId": sheetId,
"startColumnIndex": 2,
"endColumnIndex": 4,
"startRowIndex": 0,
"endRowIndex": 1,
},
"cell": {
"userEnteredFormat": {
"backgroundColor": {
"red": 1.0,
"green": 0.0,
"blue": 0.0
},
}
},
"fields": "userEnteredFormat(backgroundColor)"
}
}
]}
servicebot.spreadsheets().batchUpdate('19G_4_m-H_jLjXHKxb5Q4PyHSf1Tv9GgbQP-13F95tjQ', body=reqs).execute
highlight(0)
当我运行它时,我得到了错误
^{pr2}$我怎么能避开这个问题呢?我做错什么了
已经有一段时间了,希望这有帮助。 我认为执行应该是一种方法。这意味着您需要执行
servicebot.spreadsheets().batchUpdate('19G_4_m-H_jLjXHKxb5Q4PyHSf1Tv9GgbQP-13F95tjQ', body=reqs).execute()
来运行该功能。在:)
相关问题 更多 >
编程相关推荐