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

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

相关推荐
IT方大同5 分钟前
java输入输出+方法
java·开发语言·python
Java后端的Ai之路1 小时前
Python 进阶探索30 - Python中的装饰器
开发语言·人工智能·python·文件处理·装饰器模式
言乐61 小时前
Python基于关键词分拣快递(适用于电商与货运代理等)
开发语言·python·django·virtualenv·pygame
代码方舟1 小时前
Python数据工程:利用天远名下车辆车牌查询A优化个人债务重组与清偿能力评估合规体验
人工智能·python
卷无止境1 小时前
当AI写代码遇见Rust为什么会卡壳
后端·python
栈溢出了1 小时前
LangGraph State、节点与动态路由学习笔记
python
用户019027581611 小时前
A 股代码后缀 .SH/.SZ/.BJ 怎么区分?Python 怎么统一处理沪深京港美股代码?
python
迅猛龙办公室1 小时前
python实现简单进度条
java·前端·python
郝学胜_神的一滴1 小时前
AI 编程智能体 06:用Anaconda搞定Python多环境,彻底告别版本兼容灾难
人工智能·python
清水白石0081 小时前
Python 对象模型深度解析:从“一切皆对象”到 id、type、isinstance 底层机制与小整数缓存原理
开发语言·python·缓存