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

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

相关推荐
Zenova EdgeOS2 分钟前
Python 工业边缘 redis-py 异步实战
开发语言·redis·python
caoerzhong36 分钟前
JeeWMS 开源仓库管理系统权限与域验证解析:Java WMS 如何把数据权限管到仓、货主与人
java·python·开源·vue
一木 之林37 分钟前
Miniconda 安装与 Jupyter 使用入门
ide·python·jupyter
抓不住时间的沙1 小时前
Butterfly主题 5.7 导航栏添加相册同时设置相册入口密码
css·python·node.js
风合星语1 小时前
2026 机器人工程实例(五):让 Allegro Hand 在 MuJoCo 中完成接触抓取——抓取状态机、稳定抬升与受控释放
c++·python·机器人·仿真
隐擎fox2 小时前
解构无感人机验证底层机制:行为生物轨迹采样、环境评分模型与自动化对抗实战
自动化测试·python·网络协议·tcp/ip·网络爬虫
haidao0312 小时前
氙灯光源技术特性及其在光催化实验中的标准化应用研究
人工智能·python·能源
用户0332126663672 小时前
使用 Python 设置 Excel 行列自适应 【代码示例】
python·excel
Ticnix3 小时前
RAG 的坑不在检索,在"对齐":pgvector 实战手记
python·agent·全栈
kyrie_sakura3 小时前
python学习笔记14 -- FastAPI
笔记·python·学习·fastapi