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

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

相关推荐
烂蜻蜓几秒前
Flask入门教程(八):视图函数详解——请求处理与响应的核心
后端·python·flask
河南凹凸环境艺术设计12 分钟前
民宿酒店设计实力公司
大数据·人工智能·python
小江的记录本17 分钟前
【AI Agent】《2026年9月 AI Agent全栈开发技术选型专项面试宝典》
java·spring boot·python·spring·ai·面试·ai编程
春涧草茶39 分钟前
慢就是快-11-1数据容器 | 列表
python
维克兜率天43 分钟前
【维克】技术指标是什么:从均线到MACD的数学原理
人工智能·笔记·python·算法·量化
卷无止境1 小时前
当FastAPI遇上机器学习,一个脚手架工具能省下多少工夫
后端·python·fastapi
卷无止境1 小时前
Kilo CLI 到底是什么
人工智能·后端·python
SurpriseDPD2 小时前
bpftrace‑tasks 工具代码分析
开发语言·python
BS30813_vx2 小时前
【编号:01652】Spring Boot村务管理系统:财务公开、党建活动与计生服务一体化实战
开发语言·python
边吃番茄边敲代码2 小时前
从本地工具到 MCP:给 Agent 接入独立工具服务,并补齐自动化测试
人工智能·python·功能测试·ai·单元测试·pytest