Python:从列表列表中删除元组

时间:2010-03-14 15:13:33

标签: python list tuples

我有一个包含元组的列表列表:

[[(1L,)], [(2L,)], [(3L,)], [(4L,)], [(5L,)]

如何编辑列表,使列表如下所示:

l = [[1][2][3][4][5]]

1 个答案:

答案 0 :(得分:6)

>>> a
[[(1L,)], [(2L,)], [(3L,)], [(4L,)], [(5L,)]]
>>> a = [[x[0][0]] for x in a]
>>> a
[[1L], [2L], [3L], [4L], [5L]]