码迷,mamicode.com
首页 > 编程语言 > 详细

python一个列表根据某个元素前后分割

时间:2020-05-28 21:53:08      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:itertools   列表   style   python   ==   lambda   too   not   col   

from itertools import groupby
result = [list(g) for k, g in groupby(data, lambda x:x==‘‘) if not k]
print(result)

python一个列表根据某个元素前后分割

标签:itertools   列表   style   python   ==   lambda   too   not   col   

原文地址:https://www.cnblogs.com/lihui123/p/12983821.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!