这是我的代码:
[[[3], [4]], [[5], [6]], [[7], [8]]]
如何将其更改为:
[[3], [4], [5], [6], [7], [8]]
答案 0 :(得分:2)
您希望展平输入列表的单个级别,请使用列表解析来尝试此解决方案:
lst = [[[3], [4]], [[5], [6]], [[7], [8]]]
[e for sl in lst for e in sl]
=> [[3], [4], [5], [6], [7], [8]]
答案 1 :(得分:1)
试试这个:
$ ipcs -m
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000002 32768 myid 600 2097152 1
答案 2 :(得分:1)
未压缩或漫长的道路:
l3d = [[[3], [4]], [[5], [6]], [[7], [8]]]
l2d = []
for e1 in l3d:
for e2 in e1:
l2d.append(e2)