首页 > 编程语言 > 详细

python列表操作方法

时间:2018-01-28 23:55:48      阅读:336      评论:0      收藏:0      [点我收藏+]

系统的列表操作方法不加赘述,这里增添一些列表操作技巧:

1、利用sum函数把多元列表变成一元:

>>> texts_filtered_stopwords
[[‘writing‘, ‘ii‘, ‘rhetorical‘, ‘composing‘, ‘rhetorical‘, ‘composing‘], [‘engages‘, ‘series‘, ‘interactive‘, ‘reading‘], [‘research‘, ‘composing‘, ‘activities‘, ‘along‘, ‘assignments‘, ‘designed‘, ‘help‘]]
>>> all_stems = sum(texts_filtered_stopwords,[])
>>> all_stems
[‘writing‘, ‘ii‘, ‘rhetorical‘, ‘composing‘, ‘rhetorical‘, ‘composing‘, ‘engages‘, ‘series‘, ‘interactive‘, ‘reading‘, ‘research‘, ‘composing‘, ‘activities‘, ‘along‘, ‘assignments‘, ‘designed‘, ‘help‘]

 

python列表操作方法

原文:https://www.cnblogs.com/yqpy/p/8372814.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!