鱼C论坛

 找回密码
 立即注册
楼主: 小甲鱼

[一行流] 请用一行代码找出多于5个字符的单词

  [复制链接]
发表于 2022-7-13 08:47:12 | 显示全部楼层
w = [i for i in text.split() if len(i) > 5]
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-7-14 10:10:39 | 显示全部楼层
x = [i for i in text.split() if len(i) > 5]
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-7-18 21:13:15 | 显示全部楼层
w = [each for each in text.split() if len(each) > 5]
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-7-18 21:18:22 | 显示全部楼层
学习一下
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-8-2 18:14:08 | 显示全部楼层
  1. list(filter([i for i in text.split(' ')], len(i)>5))
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-8-2 21:03:23 | 显示全部楼层
大佬666大佬777大佬888
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-8-3 17:24:28 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2022-8-21 16:55:47 | 显示全部楼层
w = [each for each in text.split() if len(each) > 5]

import re

w = [each for each in re.split(' |,|;|\\n', text) if len(each) > 5]
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-8-24 09:31:10 | 显示全部楼层
  1. >>> text = """
  2. Once upon a time there were three little sisters,
  3. the Dormouse began in a great hurry;
  4. and their names were Elsie, Lacie, and Tillie;
  5. and they lived at the bottom of a well.
  6. ‘What did they live on?’ said Alice,
  7. who always took a great interest in questions
  8. of eating and drinking."""
  9. >>>
  10. >>> w = [x for line in text.split('\n') for x in line.split() if len(x) > 5]
  11. >>>
  12. >>> print(w)
  13. ['little', 'sisters,', 'Dormouse', 'hurry;', 'Elsie,', 'Lacie,', 'Tillie;', 'bottom', 'Alice,', 'always', 'interest', 'questions', 'eating', 'drinking.']
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-8-26 17:24:46 | 显示全部楼层
先看答案
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-9-7 17:06:53 | 显示全部楼层
  1. [i for i in text.split() if len(i) > 5]
  2.   
  3. ['little', 'sisters,', 'Dormouse', 'hurry;', 'Elsie,', 'Lacie,', 'Tillie;', 'bottom', 'Alice,', 'always', 'interest', 'questions', 'eating', 'drinking.']
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-9-8 15:36:24 | 显示全部楼层
看答案
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-9-9 14:52:29 | 显示全部楼层
w = list(filter(lambda x:len(x)>5 , text.split()))
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-9-10 14:20:55 | 显示全部楼层
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."""
h = ""
g = []
e = 0
for i in text:
    h = h + i
    if i == " ":
        g.append(h)
        h = ""

for y in range(len(h)):
    if len(h[e]) >= 5:
        g.append(h[e])
    e = e + 1

print(i)
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-9-12 17:40:26 | 显示全部楼层
666
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2022-9-12 17:50:03 | 显示全部楼层
w=set(i for i in text.split() if len(i)> 5)
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-9-17 13:48:10 | 显示全部楼层
1
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2022-9-29 15:38:43 | 显示全部楼层
学习
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2022-10-15 15:08:47 | 显示全部楼层
1
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2022-11-2 10:11:50 | 显示全部楼层
len
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-10-1 04:58

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表