[Python] Is it possible to automate updating using gspread with a list or a dictionary

Discussão em 'Python' iniciado por Stack, Junho 27, 2025.

  1. Stack

    Stack Membro Participativo

    New python user trying to use python to automate updating a sheet using gspread. The problem is, I want to set up both my sheet id and my replacing word in a list. However if I do not include the body in the loop, it can not recognize the line variable. If I put body in the loop, or make the replacement variable list(as a tuple), it simply says unhashable type:'dict' for the body

    for line in lists:
    body = {
    {"requests": [
    {"findReplace": {
    "find": str(x),
    "searchByRegex": True,
    "range": {
    "sheetId": worksheet.id,
    "startColumnIndex": 4,
    "endColumnIndex":5
    },
    "replacement":line},}
    ,
    ]
    }
    }
    x=x+1
    sh.batch_update(body)

    Continue reading...

Compartilhe esta Página