[英]Is there a gspread print function/syntax error when using "pasteType": "PASTE_VALUES"?
(Beginner) I am attempting to copy and paste specific values from one google sheet to another. (初学者)我试图将特定值从一个谷歌表复制并粘贴到另一个。 In another question that I asked, a user suggested this code:
在我问的另一个问题中,用户建议使用以下代码:
spreadsheetId = "###" # Please set the Spreadsheet ID.
sourceSheetName = "Sheet1" # Please set the sheet name of source sheet.
destinationSheetName = "Sheet2" # Please set the sheet name of destination sheet.
client = gspread.authorize(credentials)
spreadsheet = client.open_by_key(spreadsheetId)
sourceSheetId = spreadsheet.worksheet(sourceSheetName)._properties['sheetId']
destinationSheetId = spreadsheet.worksheet(destinationSheetName)._properties['sheetId']
body = {
"requests": [
{
"copyPaste": {
"source": {
"sheetId": sourceSheetId,
"startRowIndex": 0,
"endRowIndex": 5,
"startColumnIndex": 0,
"endColumnIndex": 5
},
"destination": {
"sheetId": destinationSheetId,
"startRowIndex": 0,
"endRowIndex": 5,
"startColumnIndex": 0,
"endColumnIndex": 5
},
"pasteType": "PASTE_VALUES"
}
}
]
}
res = spreadsheet.batch_update(body)
print(res)
However, I receive a syntax error at "pasteType": "PASTE_VALUES"
Why is this happening and how can I fix it?但是,我在
"pasteType": "PASTE_VALUES"
处收到一个语法错误"pasteType": "PASTE_VALUES"
为什么会发生这种情况,我该如何解决?
前一行缺少逗号
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.