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

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

相关推荐
一晌小贪欢12 分钟前
第26节:自动化办公——利用 Python 自动生成动态分析报告 (PPT/PDF)
开发语言·python·数据分析·自动化·powerpoint·pandas·数据可视化
西西弗Sisyphus32 分钟前
YOLO26 自定义损失函数 重写 init_criterion 方法 损失类不继承基类
pytorch·python·yolo·yolo11·yolo26
装不满的克莱因瓶1 小时前
RLHF中的PPO算法——大语言模型对齐优化的核心引擎
人工智能·python·深度学习·算法·机器学习·语言模型·自然语言处理
c_lb72881 小时前
期货主连研究具体月实盘:KQ 连续与标的月份偏差怎么记
python·区块链
绘梨衣5471 小时前
采集基类设计遇到的描述符bug
爬虫·python·bug
TechWayfarer1 小时前
IP精准定位服务在保险行业的接入实践:区域需求洞察与精准服务
数据库·python·tcp/ip·flask
Li#2 小时前
AI编写操作使用说明书需要用到的工具和能力
python·ai编程·ai写作
红宝村村长2 小时前
torch.autograd.Function.apply()
开发语言·python
花间相见2 小时前
【LeetCode01】—— 无重复字符的最长子串:滑动窗口经典题详解
python·算法·leetcode
何以解忧,唯有..2 小时前
Python 中的继承机制:从基础到高级用法详解
java·开发语言·python