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

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

相关推荐
郝学胜_神的一滴4 分钟前
Python 高级编程 027:四大推导式全攻略
python·pycharm
菜冻鱼14 分钟前
Python-sklearn-特征工程
开发语言·人工智能·python·机器学习·numpy·matplotlib·sklearn
mit6.82422 分钟前
archived
后端·python·flask
船长@25 分钟前
FastAPI 快速上手:从零基础到实操入门
python·ai·fastapi
我要两颗404西柚1 小时前
2【python】:常用关键字,函数,方法
python
COOLMO研究AI1 小时前
Python 如何给 AI API 实现断路器模式:防止雪崩与保护本地服务
人工智能·python·php
zzzzzz3101 小时前
LLM 成本治理:从 token 账单到线上熔断,团队应该先做哪三件事?
人工智能·python·api
AC赳赳老秦2 小时前
网页公开附件自动采集:OpenClaw 批量下载页面内嵌 Word/Excel 附件,统一格式后结构化入库
java·python·word·php·excel·deepseek·openclaw
北斗落凡尘2 小时前
LangGraph 入门实战(3)
python·langchain
TAN-90°-2 小时前
Deep Learning for Computer Vision——Image Classification with Linear Classifiers
python·深度学习·算法·计算机视觉·线性回归