Python 谷歌表单API,字体颜色,一次更新多个范围

Python 谷歌表单API,字体颜色,一次更新多个范围,python,google-sheets-api,Python,Google Sheets Api,我目前通过在多个范围内循环更新多个范围。现在,我正试图通过一次调用更新所有范围。但我不知道第二个射程放在哪里。我认为这是可能的。我不知道。这是我的密码 from multicore import g key = '1-I9CugmHB1Ds6n1jBy4Zo4hk_k4sQsTmOFfccxRc2qo' robo_font_color = [0.6, 0.0, 0.3] range1 = {'sheetId': 184514576, 'startRowIndex': 2, 'endRowI

我目前通过在多个范围内循环更新多个范围。现在,我正试图通过一次调用更新所有范围。但我不知道第二个射程放在哪里。我认为这是可能的。我不知道。这是我的密码

from multicore import g

key = '1-I9CugmHB1Ds6n1jBy4Zo4hk_k4sQsTmOFfccxRc2qo'
robo_font_color = [0.6, 0.0, 0.3]


range1 = {'sheetId': 184514576, 'startRowIndex': 2, 'endRowIndex': 3, 'startColumnIndex': 6, 'endColumnIndex': 9}
range2 = {'sheetId': 184514576, 'startRowIndex': 0, 'endRowIndex': 3, 'startColumnIndex': 1, 'endColumnIndex': 2}


def font_color(key, color):  # color is a 1x3 list
    data = {"requests": [{
        "repeatCell": {
            "range": range1,
            
            
            "cell": {
                "userEnteredFormat": {
                    "textFormat": {
                        "foregroundColor": {  # color of text
                            "red": color[0],
                            "green": color[1],
                            "blue": color[2]
                        },
                    }
                }
            },
            "fields": "userEnteredFormat.textFormat.foregroundColor"
        }
        
    }]
    }
    g.service.spreadsheets().batchUpdate(spreadsheetId=key, body=data).execute()


    
font_color(key,robo_font_color)

我应该把
range2
放在哪里,以便一次调用就更新两个范围?

这个修改怎么样

在您的情况下,如何使用
[range1,range2]
创建请求

修改脚本: 参考资料:
from multicore import g

key = '1-I9CugmHB1Ds6n1jBy4Zo4hk_k4sQsTmOFfccxRc2qo'
robo_font_color = [0.6, 0.0, 0.3]

range1 = {'sheetId': 184514576, 'startRowIndex': 2, 'endRowIndex': 3, 'startColumnIndex': 6, 'endColumnIndex': 9}
range2 = {'sheetId': 184514576, 'startRowIndex': 0, 'endRowIndex': 3, 'startColumnIndex': 1, 'endColumnIndex': 2}

def font_color(key, color, ranges):  # color is a 1x3 list
    data = {"requests": [{
        "repeatCell": {
            "range": r,
            "cell": {
                "userEnteredFormat": {
                    "textFormat": {
                        "foregroundColor": {  # color of text
                            "red": color[0],
                            "green": color[1],
                            "blue": color[2]
                        },
                    }
                }
            },
            "fields": "userEnteredFormat.textFormat.foregroundColor"
        }
    } for r in ranges]}
    g.service.spreadsheets().batchUpdate(spreadsheetId=key, body=data).execute()


font_color(key,robo_font_color, [range1, range2])