【发布时间】:2018-08-16 19:45:17
【问题描述】:
我需要使用 Python 为 Google 电子表格的多次更新创建正文。
我使用了 Python 字典 dict(),但这不适用于重复的多个值,因为 dict() 不允许多个键。
我的代码 sn-p 是:
body = {
}
for i in range (0,len(deltaListcolNames) ):
rangeItem = deltaListcolNames[i]
batch_input_value = deltaListcolVals[i]
body["range"] = rangeItem
body["majorDimension"] = "ROWS"
body["values"] = "[["+str(batch_input_value)+"]]"
batch_update_values_request_body = {
# How the input data should be interpreted.
'value_input_option': 'USER_ENTERED',
# The new values for the input sheet... to apply to the spreadsheet.
'data': [
dict(body)
]
}
print(batch_update_values_request_body)
request = service.spreadsheets().values().batchUpdate(
spreadsheetId=spreadsheetId,
body=batch_update_values_request_body)
response = request.execute()
【问题讨论】:
标签: python api dictionary