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

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

相关推荐
股朋公式网8 分钟前
斩仙飞刀、 通达信飞刀 源码
python·算法
不吃橘子的橘猫8 分钟前
NVIDIA DLI 《Build a Deep Research Agent》学习笔记
开发语言·数据库·笔记·python·学习·算法·ai
学Linux的语莫13 分钟前
python的基础使用
开发语言·python
万粉变现经纪人23 分钟前
如何解决 pip install SSL 报错 ValueError: check_hostname requires server_hostname 问题
网络·python·网络协议·beautifulsoup·bug·ssl·pip
逻极24 分钟前
FastAPI + SQLAlchemy 现代API项目实战:从零到上手的Python MySQL开发指南
python·mysql·fastapi·异步·sqlalchemy
吃人陈乐游刘28 分钟前
06实战经验X-anylabelingAI自动标注数据集-本地实现-方法二(2025年12月)保姆级教程
python·miniforge·xanylabeling
玄同76528 分钟前
Python 正则表达式:LLM 噪声语料的精准清洗
人工智能·python·自然语言处理·正则表达式·nlp·知识图谱·rag
2401_8414956433 分钟前
【机器学习】BP神经网络
人工智能·python·神经网络·机器学习·梯度下降法·反向传播·前向传播
Pyeako35 分钟前
机器学习--K-means聚类&DBSCAN&TF-IDF
python·机器学习·kmeans·tf-idf·聚类·dbscan
liu****38 分钟前
01_NumPy讲义
开发语言·python·numpy·python高级语法