python - Python & Google Sheets - 在第 5 行和第 3 列中查找元素
问题描述
所以我想做这样的事情
sheet.row_values(5).col_values(3)
但这行不通,我只找到了类似的东西
sheet.col_values(3)
但这会给我第 3 列的每个项目,但我想要第 5 行和第 3 列中的项目。这样的事情可能吗?谢谢。
编辑:最后它应该是这样的:
Item = sheet.row_values(5).col_values(3)
if not Item:
sheet.insert(row, 5, col, 3, 'text') # That won't work too, I would be happy if someone could help me with that too
解决方案
好吧,所以我以某种方式做到了。下面是代码(此脚本仅检查 HWID):
hwids = sheet.cell(i, 3)
if str(hwids) == f'<Cell R{i}C3 \'\'>':
sheet.update_cell(i, 3, hwid)
hwidd = f'<Cell R{i}C3 \'{hwid}\'>'
hwids = sheet.cell(i, 3)
if str(hwidd) == str(hwids):
print('yay, it's right!')
你需要那个 <Cell R{i}C3 ''> 因为 sheet.cell 是一个单元格,如果你不这样做,它将无法工作。{i} 是行号,我通过用户名检查得到了它,如果你也想这样做,请转到我的最后一个问题,你会看到我的答案。我希望我能帮助那些可能想做同样事情的人!