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 小时前
Python简单网络爬虫教程
爬虫·python
Patrick在香港8 小时前
Claude Prompt 香港场景:公文里「今日」落在 6 个日历日上,「翌日」锚错了 5 天
python·自然语言处理·正则表达式·claude·数据清洗
YsyaaabB8 小时前
Python 数值分析
python
阿洛学长8 小时前
计算机二级 Python 基本操作题(15 分)真题笔记(0101 ~ 1903 全套)
python·pycharm
weixin199701080169 小时前
[特殊字符]️《二手ERP对接电商平台的总体方案:统一数据模型 + 事件驱动 + 灰度上线6原则》(附Python源码)
大数据·python
滚雪球~9 小时前
量化交易 防止Windows电脑自动更新并重启
python·量化
L@ncor10 小时前
第二章可能出现的问题
人工智能·python
y = xⁿ10 小时前
大模型基础概念
python
ctlover11 小时前
排序与查找算法详解
开发语言·python
用户83562907805111 小时前
如何使用 Python 给 Word 文档添加水印
后端·python