简体   繁体   English

Python/gspread 模块 - 给定一个表示坐标的元组列表,用一个值更新所有这些单元格?

[英]Python/gspread module - Given a list of tuples representing coordinates, update all these cells with one single value?

Im struggling since yesterday with this problem, can't iterate too much cause I get rate limited by google, cause of perfomrnace, would also prefer not to even with an higher limit.我从昨天开始就在这个问题上苦苦挣扎,不能重复太多,因为我的速度受到谷歌的限制,性能的原因,也不想有更高的限制。

I have the following:我有以下内容:

#list of tuples representing (row,col)
list_of_tuples = [(27, 2), (28, 2), (29, 2), (30, 2), (31, 2), (32, 2), (33, 2), (34, 2), (35, 2), (36, 2), (37, 2), (38, 2), (39, 2), (40, 2), (41, 2), (42, 2), (43, 2), (44, 2), (45, 2), (46, 2), (47, 2), (48, 2), (49, 2), (50, 2), (51, 2), (52, 2), (53, 2), (54, 2), (55, 2), (56, 2), (57, 2), (58, 2), (59, 2), (60, 2), (61, 2), (62, 2), (63, 2), (64, 2), (65, 2), (66, 2), (67, 2), (68, 2), (69, 2), (70, 2), (71, 2), (72, 2), (73, 2), (74, 2), (75, 2), (76, 2)]

#udpate these cells in the worksheet with  the string "DONE"
worksheet.update_cells(list_of_tuples, "DONE")

Can't really find something that could make it...真的找不到可以做到的东西......

Thanks guys!!多谢你们!!

Omg, finally:天哪,最后:

    cell_range = worksheet.range(f'B{list_of_tuples [0][0]}:B{list_of_tuples [-1][0]}')
    for cell in cell_range:
        cell.value = "DONE"

    worksheet.update_cells(cell_range)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM