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

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

相关推荐
Gerardisite2 分钟前
如何在微信个人号开发中有效管理API接口?
java·开发语言·python·微信·php
小毛驴85033 分钟前
软件设计模式-装饰器模式
python·设计模式·装饰器模式
闲人编程1 小时前
Python的导入系统:模块查找、加载和缓存机制
java·python·缓存·加载器·codecapsule·查找器
weixin_457760001 小时前
Python 数据结构
数据结构·windows·python
合作小小程序员小小店2 小时前
web网页,在线%抖音,舆情,线性回归%分析系统demo,基于python+web+echart+nlp+线性回归,训练,数据库mysql
python·自然语言处理·回归·nlp·线性回归
q***2512 小时前
Python中的简单爬虫
爬虫·python·信息可视化
最晚的py2 小时前
Python Matplotlib
python·数据分析
柳鲲鹏2 小时前
OpenCV:文件视频防抖,python版
python·opencv·音视频
@sinner4 小时前
你好,Scikit-learn:从零开始你的第一个机器学习项目
python·机器学习·scikit-learn