代码之家  ›  专栏  ›  技术社区  ›  Nero

我应该如何提取嵌套列表以保存到数据库?

  •  0
  • Nero  · 技术社区  · 2 年前

    Unpack operation not allowed in this context
    

    我的代码:

    def save_data_to_database(self):
        parsed_records = self.parse_sheet_data()
        for record in parsed_records:
            self.db.set_item(
                "sheet", #table name
                "id, number_of_order, cost, delivery_time" # These are fields in table
                f"{*record}" # Here I'm trying to unpack values, but I can't
            )
    

    “parsed_记录”的值如下所示:

    [['1', '1249708', '675', '24.05.2022'], ['2', '1182407', '214', '13.05.2022'], ['3', ...]]
    

    若你们看到上面的代码,我想用“*”打开记录,但我不能。 我应该如何将记录保存到db?

    2 回复  |  直到 2 年前
        1
  •  0
  •   sifat    2 年前

    看看这能不能解决你的问题

    ,.连接(记录)

        2
  •  0
  •   MorningSciFi    2 年前