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

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

相关推荐
啊阿狸不会拉杆6 分钟前
《机器学习导论》第 18 章-增强学习
人工智能·python·学习·算法·机器学习·智能体·增强学习
查无此人byebye7 分钟前
基于DiT+DDPM的MNIST数字生成:模型推理实战教程
人工智能·python·深度学习·nlp·transformer
我的xiaodoujiao10 分钟前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 48--本地环境部署Jenkins服务
python·学习·测试工具·pytest
喵手13 分钟前
Python爬虫实战:爬取得到App电子书畅销榜 - 从零到交付的完整实战!
爬虫·python·爬虫实战·零基础python爬虫教学·爬取app电子书畅销榜·app电子书畅销榜单数据获取
2401_8288906414 分钟前
实现变分自编码器 VAE- MNIST 数据集
人工智能·python·深度学习·cnn·transformer
PD我是你的真爱粉16 分钟前
RabbitMQ架构实战
python·架构·rabbitmq
我的xiaodoujiao18 分钟前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 49--CI/CD-开始探索使用Jenkins
python·学习·测试工具·ci/cd·jenkins·pytest
南 阳19 分钟前
Python从入门到精通day35
数据库·python·oracle
geovindu9 小时前
python: Memento Pattern
开发语言·python·设计模式·备忘录模式
寻星探路9 小时前
【JVM 终极通关指南】万字长文从底层到实战全维度深度拆解 Java 虚拟机
java·开发语言·jvm·人工智能·python·算法·ai