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

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

相关推荐
夏日清风有你15 分钟前
OpenDataLab 数据集下载
python
黑客-秋凌16 分钟前
使用Python+selenium实现第一个自动化测试脚本
开发语言·自动化测试·软件测试·python·selenium·测试工具
DogDaoDao1 小时前
【GitHub】WorldMonitor:一个工程极致主义的实时全球情报仪表盘深度解析
python·程序员·架构·github·go语言·worldmonitor·实时全球情报
艾斯特_2 小时前
混合检索与重排:提升召回与排序质量
后端·python·ai
网安墨雨2 小时前
MySQL数据库 SQL语句详解
自动化测试·软件测试·数据库·python·sql·mysql
柠檬味的Cat2 小时前
GEO优化系统哪家技术强
人工智能·python
跨境小陈2 小时前
2026 年如何使用 Python 抓取 Reddit 数据
开发语言·网络·python
殿方雪之下2 小时前
OpenAI 兼容 API 接入实战:统一 Base URL 与用量控制
python
今天AI了吗2 小时前
Spring AI 框架实战:Java 后端集成大模型的架构设计与工程落地
java·人工智能·python·spring·机器学习
艾派森3 小时前
Web Scraper API vs 自建爬虫:一次真实对比测试,结果让人震惊
爬虫·python·网络爬虫