gpt4 book ai didi

python - 检查字符串是否包含我的列表中的两个或多个单词(python)

转载 作者:行者123 更新时间:2023-12-01 02:48:58 26 4
gpt4 key购买 nike

我正在尝试从文本中提取相关信息。

我现在使用Python。

因为,如果有的话(mytext 中的 s 对应 mylist 中的 s):

搜索太多不相关的字符串,

我正在尝试从我的列表中查找包含两个或多个单词的字符串。

所以,我的问题是“我如何才能只从列表中选择包含两个或更多单词的句子”

感谢您的帮助!

祝你有美好的一天!

最佳答案

我没有得到你想要的,但我的理解是:

list = ["This is tesing", "hello","My name", "This is not test"]
for sentense in list :
if len(sentense.split()) >= 2:
print sentense

输出:

This is tesing
My name
This is not test

希望这对你有帮助...

关于python - 检查字符串是否包含我的列表中的两个或多个单词(python),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45004916/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com