2024-06-11 09:07:44 发布
网友
我得到了以下代码:
import re text = "He was carefully disguised but captured quickly by police." print re.findall(r"\w+ly", text)
现在的输出是:
['carefully', 'quickly']
我怎样才能使我的re.findall这样,它将显示它发现某物的整行。就像当有很多tekst的时候,我在搜索所有有我名字的东西。我怎么能让它显示整个tekst行,而不仅仅是我的名字
检查re.findall()是否返回任何内容,然后打印该行:
re.findall()
text = "He was carefully disguised but captured quickly by police." lines = [text, 't', 'l'] for line in lines: if re.findall(r"\w+ly", line): print line
检查
re.findall()
是否返回任何内容,然后打印该行:相关问题 更多 >
编程相关推荐