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

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

相关推荐
天才测试猿7 小时前
2026软件测试面试八股文(含答案+文档)
自动化测试·软件测试·python·功能测试·测试工具·面试·职场和发展
张小凡vip8 小时前
python--爬虫--成熟的爬虫框架Scrapy
爬虫·python·scrapy
Pluchon8 小时前
Java个人综合项目——萌部落社区V2.0
java·python·spring·spring cloud·postman·idea
不瘦80斤不改名9 小时前
01-vibe-coding-起源与本质
人工智能·python
夜雪一千9 小时前
如何对新闻数据进行模糊去重
python
oyguyteggytrrwwwrt11 小时前
3dgs渲染部分详细注释
python
天天爱吃肉821813 小时前
【重磅发布:拿下新超仁达代理权 】
大数据·人工智能·python·功能测试·汽车
神王宝宝 王者小学13 小时前
面向领域驱动架构的查询实现方式
前端·python·架构
ningmengjing_14 小时前
Redis 从入门到实战:Python操作全攻略
数据库·redis·python
️学习的小王14 小时前
智能文档助手:基于RAG的本地化文档问答系统实战指南
人工智能·python·机器学习