好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

python中平均分割列表

Python中把列表(list)分成相等大小的小list,可使用生成器。

使用生成器:

测试

for循环:

[l[i:i+n] for i in range(0, len(l), n)],l是要分割的list,n是分成多少份

测试:

以上就是python中平均分割列表的详细内容,更多请关注Gxl网其它相关文章!

查看更多关于python中平均分割列表的详细内容...

  阅读:45次