2

我有以下子列表:

[['a', 'b'], ['c', 'd'], ['e', 'f'], ['g']]

但是可以加入子列表中的列表吗?

[['ab'], ['cd'], ['ef'], ['g']]
4

2 回答 2

6
>>> L = [['a', 'b'], ['c', 'd'], ['e', 'f'], ['g']]
>>> [[''.join(x)] for x in L]
[['ab'], ['cd'], ['ef'], ['g']]
于 2013-04-03T13:21:31.920 回答
-1

此外,您可以使用地图

>>> L = [['a', 'b'], ['c', 'd'], ['e', 'f'], ['g']]
>>> map(lambda x: [''.join(x)], L)
[['ab'], ['cd'], ['ef'], ['g']]
于 2013-04-03T13:46:57.627 回答