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

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

相关推荐
YEGE学AI算法15 分钟前
Python实现Log-Mel Fbank:分帧、加窗、FFT与Mel滤波器组
python·语音识别·fbank·log-mel·音频特征
甜到心里的蛋糕18 分钟前
Playwright 无头浏览器自动发布 CSDN 图文草稿的实践(持久化 profile + 图床直传)
运维·python·playwright·爬虫自动化·博客运营
jason.zeng@15022071 小时前
(六)Prompt 优化
python·ai·langchain·prompt·ai编程·llama
全栈练习生1 小时前
大模型推理全链路
python·ai
泡海椒2 小时前
JQuick-Excel VALIDATION 实战:用作用范围约束 Excel 导入校验
开发语言·python·excel
小静AI工程实验室3 小时前
Python 爬虫解析 JSON-LD:多块 script、@graph 与坏数据的 9 个边界
爬虫·python·json
jason.zeng@15022073 小时前
(八)现有架构上新增一个通用Excel导出工具
python·架构·langchain·excel·llama
袁袁袁袁满3 小时前
AI Agent 如何“看懂“互联网?
爬虫·python·自动化·爬虫实战·多线程爬虫
泡海椒3 小时前
JQuick-Excel 实战:用 VALIDATION 建立可维护的 Excel 导入校验
开发语言·python·excel
Duang007_3 小时前
生产可观测性:从“系统慢“到“根因“的完整链路(Go / TypeScript)
后端·python·golang·typescript·prometheus