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

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

相关推荐
Mr_Xuhhh2 小时前
Java泛型进阶:从基础到高级特性完全指南
开发语言·windows·python
老天文学家了3 小时前
蓝桥杯备战Python
开发语言·python
ID_180079054734 小时前
除了 Python,还有哪些语言可以解析 JSON 数据?
开发语言·python·json
FreakStudio5 小时前
小作坊 GitHub 协作闭环:fork-sync-dev-pr-merge 实战指南
python·单片机·嵌入式·面向对象·电子diy
普通网友6 小时前
阿里云国际版服务器,真的是学生党的性价比之选吗?
后端·python·阿里云·flask·云计算
小陈工6 小时前
2026年4月2日技术资讯洞察:数据库融合革命、端侧AI突破与脑机接口产业化
开发语言·前端·数据库·人工智能·python·安全
陈晓明start6 小时前
【python】豆包模型,自动生成测试用例初探索
python
阿kun要赚马内7 小时前
Python中元组和列表差异:底层结构分析
开发语言·python
万添裁7 小时前
pytorch的张量数据结构以及各种操作函数的底层原理
人工智能·pytorch·python