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

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

相关推荐
算法与双吉汉堡17 小时前
【Nanobot项目笔记】项目架构
python·ai·agent·智能体
knight_9___17 小时前
LLM工具调用面试篇6
人工智能·python·面试·职场和发展·llm·agent
用户39626910600317 小时前
asyncio + subprocess:Python异步调用外部命令踩坑实录
python
AI砖家17 小时前
Claude Code Superpowers 安装使用指南:让 AI 编程从“业余”走向“工程化”
前端·人工智能·python·ai编程·代码规范
计算机毕业编程指导师18 小时前
【计算机毕设推荐】Python+Spark卵巢癌风险数据可视化系统完整实现 毕业设计 选题推荐 毕设选题 数据分析 机器学习 数据挖掘
hadoop·python·计算机·数据挖掘·spark·毕业设计·卵巢癌
玩转单片机与嵌入式18 小时前
学习嵌入式AI(TInyML),只需掌握这点python基础即可!
人工智能·python·学习
少年执笔18 小时前
ollama搭建本地模型框架
python·ai
极光代码工作室18 小时前
基于大数据的校园消费行为分析系统
大数据·hadoop·python·数据分析·spark
A__tao18 小时前
JSON 转 Java 实体类工具(支持嵌套与注释解析)
java·python·json