系统的列表操作方法不加赘述,这里增添一些列表操作技巧:
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‘]
原文地址:https://www.cnblogs.com/yqpy/p/8372814.html
时间: 2024-11-05 12:27:50