|
发表于 2022-8-24 09:31:10
|
显示全部楼层
- >>> text = """
- Once upon a time there were three little sisters,
- the Dormouse began in a great hurry;
- and their names were Elsie, Lacie, and Tillie;
- and they lived at the bottom of a well.
- ‘What did they live on?’ said Alice,
- who always took a great interest in questions
- of eating and drinking."""
- >>>
- >>> w = [x for line in text.split('\n') for x in line.split() if len(x) > 5]
- >>>
- >>> print(w)
- ['little', 'sisters,', 'Dormouse', 'hurry;', 'Elsie,', 'Lacie,', 'Tillie;', 'bottom', 'Alice,', 'always', 'interest', 'questions', 'eating', 'drinking.']
复制代码 |
|