从sqlite查询中选择特定列作为特定数组?

时间:2015-09-23 13:37:19

标签: python sqlite

我有类似的查询:

c.execute('''select FileSize, FileName, FileType from ExampleTable
    where FileType = ?''', [FileType])
bestCRThLocal = list(c.fetchall())
print(bestCRThLocal[0]);

我希望FileName,FileType和FileSize的数组各自拥有自己的数组。

在python中执行此操作的最佳方法是什么?

1 个答案:

答案 0 :(得分:1)

使用zip()。例如:

>>> l = [[1, 2, 3], [4, 5, 6],[7, 8, 9]]
>>> zip(*l)
[(1, 4, 7), (2, 5, 8), (3, 6, 9)]