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

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

相关推荐
Niuguangshuo3 分钟前
DeepFilterNet 3:端侧实时全带降噪的开源标杆
python
第一程序员20 分钟前
AI 辅助编程的 7 个误区:把模型当高级搜索引擎是对它的最大浪费
python·rust·github
Groundwork Explorer2 小时前
W5500 网卡编程初始化与使用指南
python·单片机
逸Y 仙X2 小时前
MCP(模型控制协议)完全指南:从核心概念到实战开发
python·大模型·llm·ai编程·mcp
WILLF3 小时前
前端视角:Python requests vs JS axios
前端·python
哒哒哒5285203 小时前
69. Python: 核心语法-面向对象基础-案例(教务系统)
python
何以解忧,唯有..3 小时前
Python 中获取目录操作完全指南
windows·python·microsoft
南京云森杉木桩3 小时前
常见打桩木品牌推荐,选对材质让工程更稳固
人工智能·python·材质
总有刁民想爱朕ha3 小时前
Python PyQt5图片批量转MP4视频工具:本地离线免费无水印,完整代码
开发语言·python·qt
zyj8890913 小时前
濮阳工厂目视化设计安全警示牌材质怎么选耐用
python·安全·材质