【问题标题】:Python - Combine two lists - Title and DataPython - 结合两个列表 - 标题和数据
【发布时间】:2017-11-03 20:48:49
【问题描述】:

我正在使用 SQLite。

我有两个列表。 res1 保存我的sql查询结果的标题,它只包含两个值(/最终列表的列)和res2 保存数据的列表(二维)。

我如何将res 列表分配给res1,然后在其后追加/扩展/插入res2 列表,使其看起来像这样。

|Column1  | Column2|
|row1Val1 | row1Va2|
|row2Val1 | row2Va2|
|row3Val1 | row3Va2|
|row4Val1 | row4Va2|

等等。

我已经尝试过,在特定索引处插入,扩展等。他们不工作。如果没有 for / 循环迭代,我怎么能做到这一点?一定有这样的功能,或者做这么简单的事情的方法。谢谢。

【问题讨论】:

    标签: python list sqlite iterable


    【解决方案1】:

    要么我不明白你问什么,要么答案很简单:

    res = [res1] + res2
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-03
      • 1970-01-01
      • 2020-09-30
      • 2016-12-12
      • 2014-01-03
      • 1970-01-01
      • 2013-02-07
      相关资源
      最近更新 更多