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

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

相关推荐
2601_9578838416 分钟前
2026年8月:外星人笔记本维修服务揭秘
python·电脑
eric-sjq21 分钟前
仅0.6B参数如何锁住超长记忆?Xiaothink-T17-RWKV5-MLA 架构深度解析:RWKV-v5 × MLA 的“降维打击“
python·架构
张小凡vip37 分钟前
Python爬虫实战:高效稳定的文件下载模块设计与实现
开发语言·爬虫·python
小趴蔡ha9 小时前
02 Anaconda、Python 与机器学习开发环境入门
python·机器学习·anaconda
2401_868534789 小时前
RTOS之RT-Thread & Linux:线程/进程管理与调度核心差异分析
c++·python
数字化转型分享点滴10 小时前
富士康、蓝思科技为何选择四化信息?MES制造执行系统的实践
python·科技
wling030110 小时前
vasp虚频计算-python脚本
开发语言·windows·python·vasp计算
魔镜前的帅比10 小时前
(开源项目)x-claw(总)
python·ai·rust·开源
xrandzj11 小时前
Python面向对象编程入门:类、实例、初始化与封装实践
开发语言·python
matlabgoodboy14 小时前
计算机毕设代做|Java Python Matlab APP 全套开发设计
java·python·课程设计