一、将大列表拆分为小列表
>>> a = [1,2,3,4,5,6,7,8,9,0]
>>> n = 3
>>> c= [a[i:i+n] for i in range(0, len(a), n)]
二、将大列表套小列表转化为一个列表
>>> a
[[1], [2], [3]]
>>> b = []
>>> [b.extend(li) for li in a]
[None, None, None]
>>> b
[1, 2, 3]
>>> a = [1,2,3,4,5,6,7,8,9,0]
>>> n = 3
>>> c= [a[i:i+n] for i in range(0, len(a), n)]
>>> a
[[1], [2], [3]]
>>> b = []
>>> [b.extend(li) for li in a]
[None, None, None]
>>> b
[1, 2, 3]
转载于:https://www.cnblogs.com/Frange/p/9140004.html