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

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

相关推荐
名字还没想好☜5 分钟前
Spring @EventListener 事件驱动解耦实战:同步转异步、事务绑定与顺序控制
java·数据库·后端·python·spring
ellenwan20261 小时前
看到“最新 AI 量化学习”时,先让表达变清楚
人工智能·python
海宇数据2 小时前
零信任架构实战:基于海宇柠檬查出险-登记证构建自动化残值评估网关
人工智能·python·架构·自动化
李可以量化2 小时前
Tornado 如何增加网页操作(下)
python
zhangzeyuaaa2 小时前
深入理解 pip install .:安装当前目录项目的正确姿势
人工智能·python·pip
Jazz_z3 小时前
纯 Python 环境下 Excel 文件的读取与导入详解
python
Thomas.Sir3 小时前
第38课:TensorFlow|可视化工具TensorBoard全用法【日志写入、指标监控、网络可视化】
人工智能·python·tensorflow
SEO_juper3 小时前
外贸多语言站最隐蔽的流量杀手:hreflang 错了,谷歌把德语页推给美国人(附审计脚本)
开发语言·前端·python·seo·独立站·谷歌优化
Metaphor6924 小时前
快速合并 Word 文档【Python 指南】
python·word
JAVA老架构AI智能化4 小时前
如何高质量分块
人工智能·python