【问题标题】:Delete columns in Google Sheet with python in a test with Selenium在使用 Selenium 的测试中使用 python 删除 Google Sheet 中的列
【发布时间】:2021-04-02 19:31:11
【问题描述】:

我正在尝试使用 gspread 清除 Google 表格中的某些列,因此更适合的是 insert_cols () 函数,但它返回错误。我尝试使用 update() 但它也不起作用。

sheet.delete_columns(1,15)
    
sheet.insert_cols(1,15)

然后返回

TypeError: object of type 'int' has no len()

【问题讨论】:

    标签: python selenium google-sheets


    【解决方案1】:

    insert_cols 的第一个参数接受一个列表。你传递的是一个 int,所以当函数试图在 int 上调用 len 时,你会得到一个 TypeError。

    尝试更改为sheet.insert_cols([1, 15])

    【讨论】:

      【解决方案2】:

      你检查过你的命令是否正确吗?

      点击here

      用于 deleteColumns(columnPosition, howMany) 的工作表 API

      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var sheet = ss.getSheets()[0];
      // Columns start at "1" - this deletes the first two columns
      sheet.deleteColumns(1, 2);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-01-22
        相关资源
        最近更新 更多