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

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

相关推荐
2301_800074216 小时前
map,list简单方法
windows·python·list
DeepVisionary7 小时前
30B 参数打平 1 万亿参数:Meta 开源 Muse Glimmer,跑分 35 对 36
python·自动化
吴声子夜歌8 小时前
Guava——基本工具(二)
windows·python·guava
用户8356290780519 小时前
使用 Python 管理 PDF 属性和元数据
后端·python
猎嘤一号9 小时前
【2026 最新】Windows 11 右键菜单还原为 Windows 10 经典样式:一条命令、原理、回退与新版说明
windows·python
用户8356290780519 小时前
使用 Python 在 Word 文档中创建自定义图表
后端·python
kyrie_sakura10 小时前
python学习笔记11 -- 进程和线程
笔记·python·学习
Jialu.11 小时前
中文 NLP 模型部署实战:FastAPI 接口 + Streamlit 看板
人工智能·python·自然语言处理·fastapi
Asum1ta12 小时前
K8s 学习环境搭建:Python 与 PyCharm 开发环境配置指南
python·学习·kubernetes