【发布时间】:2015-01-04 11:44:47
【问题描述】:
所以这是我的第一个列表:
listone = [
'Every day Miss Leeson went out to work',
' At night she brought home papers with handwriting on them and made copies with her typewriter',
' Sometimes she had no work at night, and then she would sit on the steps of the high stoop with the other roomers',
' Miss Leeson was not intended for a sky-light room when the plans were drawn for her creation',
' She was gay-hearted and full of tender, whimsical fancies',
' Once she let Mr',
' Skidder read to her three acts of his great (unpublished) comedy, "It'
]
在这个列表中,每个句子都是一个元素,我想让每个句子成为一个子列表,或者只有句子的一部分成为一个子列表,例如:
listtwo = [['Every','Miss','work'], ['At', 'she', 'with'] etc.]
子列表中的单词是随机选择的,我已经有一个过滤功能可以使用。
感谢您的帮助!
【问题讨论】:
-
它将在每个子列表中以三个为一组??总是来自原始列表
-
[s.split() for s in listone]
标签: python string list for-loop