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

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

相关推荐
Q264336502312 分钟前
【有源码】基于Hadoop+Spark的起点小说网大数据可视化分析系统-基于Python大数据生态的网络文学数据挖掘与可视化系统
大数据·hadoop·python·信息可视化·数据分析·spark·毕业设计
大叔_爱编程43 分钟前
基于Python的历届奥运会数据可视化分析系统-django+spider
python·django·毕业设计·源码·课程设计·spider·奥运会数据可视化
Q_Q19632884752 小时前
python+django/flask基于协同过滤算法的理财产品推荐系统
spring boot·python·django·flask·node.js·php
高洁012 小时前
面向强化学习的状态空间建模:RSSM的介绍和PyTorch实现(3)
人工智能·python·深度学习·神经网络·transformer
aloha_7892 小时前
测试开发工程师面经准备(sxf)
java·python·leetcode·压力测试
Jonathan Star3 小时前
MediaPipe 在Python中实现人体运动识别,最常用且高效的方案是结合**姿态估计**(提取人体关键点)和**动作分类**(识别具体运动)
开发语言·python·分类
山顶听风3 小时前
分页条初始化
python
NewsMash4 小时前
PyTorch之父发离职长文,告别Meta
人工智能·pytorch·python
硅农深芯4 小时前
如何使用ptqt5实现进度条的动态显示
开发语言·python·qt