更具体地说,我正在遵循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)
当我运行它时,出现错误
Traceback (most recent call last):
File "C:\Users\rexfo\Desktop\autosparring\test.py", line 51, in <module>
highlight(0)
File "C:\Users\rexfo\Desktop\autosparring\test.py", line 49, in highlight
servicebot.spreadsheets().batchUpdate('19G_4_m-H_jLjXHKxb5Q4PyHSf1Tv9GgbQP-13F95tjQ', body=reqs).execute
TypeError: method() takes 1 positional argument but 2 were given
那么我该如何解决呢?我在做什么错了
答案 0 :(得分:0)
已经有一段时间了,希望对您有所帮助。
我相信execute应该是一种方法。这意味着您需要执行servicebot.spreadsheets().batchUpdate('19G_4_m-H_jLjXHKxb5Q4PyHSf1Tv9GgbQP-13F95tjQ', body=reqs).execute()
才能运行该功能。
:)