簡體   English   中英

Python/gspread 模塊 - 給定一個表示坐標的元組列表,用一個值更新所有這些單元格?

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

我從昨天開始就在這個問題上苦苦掙扎,不能重復太多,因為我的速度受到谷歌的限制,性能的原因,也不想有更高的限制。

我有以下內容:

#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")

真的找不到可以做到的東西......

多謝你們!!

天哪,最后:

    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