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

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

相关推荐
AI模型调用笔记7 小时前
流式 API 的 usage 为 null?用 cURL 看尾帧,别漏空 choices
python
天诰8 小时前
SA-T-06 轨迹数据工程 脏数据检测
人工智能·python·算法·语言模型·ai编程
Java后端的Ai之路9 小时前
Anthropic 官方文章《Building always-on agents》构建指南
开发语言·网络·python
badhope10 小时前
Agent 说发布成功,文章却 404:我补了 4 张回读收据
后端·python·ai编程
xurileidian10 小时前
第 30 篇 · 边玩边学Python · 猜数字小游戏 把判断循环异常串起来
前端·python·算法
leeshuqing11 小时前
剪刀石头布-Python练习
python·游戏·优化·列表·字典·控制语句
ZhuoAIStage11 小时前
图上有设备,机房条件0命中:剧院舞台音视频提资缺项,AI智能体为何判「需补充」不判「设计错漏」
python·正则表达式·舞台工艺·智能体审图·提资核查
汤姆宝库11 小时前
HNSW:分层图上的贪心检索
开发语言·python
呆呆虫1211 小时前
Google Custom Search API 2027 停服替代:SerpBase 等 5 种全网搜索方案对比
python·serp api·serpbase·custom search·接口迁移
絲唸11 小时前
可信机器学习与对抗鲁棒性:温度读数有误差,温室的高温判定还能信吗?
人工智能·python·深度学习·神经网络·算法·机器学习·机器人