我正在尝试从文本中提取所有包含指定单词的句子。
txt="I like to eat apple. Me too. Let's go buy some apples."
txt = "." + txt
re.findall(r"\."+".+"+"apple"+".+"+"\.", txt)
但它正在返回我:
[".I like to eat apple. Me too. Let's go buy some apples."]
代替 :
[".I like to eat apple., "Let's go buy some apples."]
有什么帮助吗?
原文由 user2187202 发布,翻译遵循 CC BY-SA 4.0 许可协议