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
"""

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

相关推荐
刘新洲25 分钟前
别再只做会聊天的 Agent:我用 1 天把工具调用做成了可验证、可评测的工程系统
人工智能·python·openai
码云骑士27 分钟前
102-向量数据增删改查-增量更新-过期策略-向量漂移重索引
python
Molecular_Chat32 分钟前
Biotin SNA 生物素偶联凝集素结合特异性、生物素标记效率定量表征研究
javascript·python
WILLF33 分钟前
Python vs JavaScript 异常处理对比
前端·python
问天_观心1 小时前
python之uv库的学习
开发语言·python
vx-程序开发1 小时前
django汽车租赁系统---附源码25360
java·javascript·spring boot·python·eclipse·django·php
笨鸟先飞,勤能补拙1 小时前
AI Agent应用领域深度解析:从概念到落地的全维度审视
大数据·人工智能·python·物联网·安全·网络安全·github
北斗落凡尘2 小时前
LangGraph 入门实战(6)
python·langchain
大模型码小白2 小时前
AI安全前沿:AI大模型安全防护的前沿技术
java·网络·人工智能·python·深度学习·学习·安全
evans在进步2 小时前
LeetCode 34:在排序数组中查找元素的首尾位置——Java 两次二分查找详解
java·python·leetcode