【python】【展平列表】

1 arr = [[1], [2, 3], [4, 5, 6]]
2 brr = sum(arr, [])
3 # [1, 2, 3, 4, 5, 6]
4 arr = [[1], [2, 3], [[4], [5], [6]]]
5 crr = sum(arr, [])
6 # [1, 2, 3, [4], [5], [6]]

 

posted @ 2021-07-28 18:03  ddzhen  阅读(82)  评论(0编辑  收藏  举报