Python 判断列表中是否有元素被另一字符串包含

Python 判断列表中是否有元素被另一字符串包含

推荐阅读

all() 函数与 any() 函数

正文

python 复制代码
lst = ['das', 'it']
str1 = 'dasAuto'

if any(text in str1 for text in lst):
    print('The string contains at least one element from the list')
else:
    print('The string does NOT contain any of the elements in the list')
"""
result:
The string contains at least one element from the list
"""

如果大家觉得有用,就请点个赞吧~

相关推荐
snhna几秒前
DeerFlow 2.x 源码拆解:多智能体委派、Skills、沙箱与 Linux 部署实战
人工智能·python
Wx-bishekaifayuan9 分钟前
springboot桂味美食分享系统40540-计算机课程设计、毕业设计
spring boot·后端·python·django·课程设计·express·旅游
Metaphor69222 分钟前
如何快速拆分超大 Excel 文件【Python 教程】
python·excel
孟健44 分钟前
从单体失控到解耦管道:用 Unix 哲学重构 Anthropic 式多 Agent 动态工作流
人工智能·python·架构
小白快快跑哦1 小时前
python-字符串全解(六):正则表达式-前后相断言
开发语言·python·正则表达式·前后相断言
kimnoic1 小时前
Python数据分析中正则表达式匹配字符串与常用函数示例详解
开发语言·python
许墨の小蝴蝶1 小时前
Pillow 替换图片文字后字号偏小的排查
python·pillow
朝朝辞暮i1 小时前
第 01 讲:Python 变量、对象、数据类型与内存引用
开发语言·python
外收内放2 小时前
Python基础语法练习题(69)
开发语言·python
TomEval2 小时前
【测AI】第11篇:深度学习基础 —— 神经网络是怎么工作的
人工智能·python·深度学习·神经网络·机器学习·aigc