当我尝试做一个batch_update gspread时错误
我在Gspread上有问题,我正在尝试做一个worksheet.batch_update,但是我收到此错误
文件“ d:\ proyectoreal-Statement \ venv \ lib \ lib \ site-packages \ gspread \ worksheet.py”,第903行,in dict(vr,range = absolute_range_name(self.title,vr ['rangy'])for数据中的VR TypeError:字符串索引必须是整数
我的代码是:
floor = [typeFloor #String, titleFloor #String, href #String, m2Floor #String, roomsFloor #Integer, priceFloor #Double]
listaFinal.append(floor)
rangeRows = 'A2' + ":F" + str(len(listaFinal))
worksheet.batch_update({
'range': rangeRows,
'values': listaFinal
})
任何知道我如何在工作表中添加大量信息,或者如何解决此问题?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
修改点:
batch_update(data)
的参数data
是一个数组。len(ListAfinal)
是1
时,该值是从单元格“ A1”中放置的。来自rangerows ='a2' +“:f” + str(len(listAfinal))
,我相信您想将值放在“ A2”中。当这些点反映到您的脚本中时,如下所示。
修改后的脚本:
或者,我认为在您的脚本中,可以使用以下修改后的脚本。
注意:
listafinal
的值是2维数组。请注意。参考:
Modification points:
data
ofbatch_update(data)
is required to be an array.len(listaFinal)
is1
, the value is put from the cell "A1". FromrangeRows = 'A2' + ":F" + str(len(listaFinal))
, I believe that you wanted to put the values from "A2".When these points are reflected to your script, it becomes as follows.
Modified script:
Or, I thought that in your script, the following modified script might be able to be used.
Note:
listaFinal
is 2 dimensional array. Please be careful about this.References: