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

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

相关推荐
Minner-Scrapy33 分钟前
Scrapy 2.17 源码解析:Scheduler 调度器与磁盘/内存双队列
java·爬虫·python·scrapy·网络爬虫·twisted
CODER030443 分钟前
Anaconda和Mamba创建环境管理包常用命令合集
python·深度学习·conda·虚拟环境·mamba·常用命令大全
闲猫1 小时前
LangGraph / Capabilities / Fault tolerance
python·agent·langgraph
IvanCodes1 小时前
Python 基础语法(一):变量、数据类型与运算符
python
程序员三藏2 小时前
浅谈性能测试
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·性能测试
l1258652 小时前
# RAG向量数据库优化实战:HNSW索引调参与生产级性能设计
数据库·python·mysql·langchain
meilindehuzi_a3 小时前
Python 基础语法(1):常量、变量、类型、输入输出与运算符
开发语言·python
Zane19943 小时前
调用了 async 函数却没执行?一文讲透协程、event loop 与 await
后端·python
OPEN-F4 小时前
Python进阶教程:装饰器与生成器深入
开发语言·python
zhipujiaoyu4 小时前
2026年大数据专科何去何从?就业前景、发展趋势全揭秘!
大数据·python