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

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

相关推荐
Metaphor6929 分钟前
使用 Python 在 Word 文档中添加、修改和删除变量
python·word
終不似少年遊*22 分钟前
【AI Coding实战方法论】从计划协作到架构护栏,一套能长期复用的工程流程
人工智能·python·团队开发·ai编程·ai coding·skills·上下文管理
lusklusklusk23 分钟前
Python 全局变量与局部变量区别——global 关键字、__main__ 块与作用域示例
开发语言·前端·python
马剑威(威哥爱编程)37 分钟前
Python 智能体开发实战 01:装了三遍环境还在报错?虚拟环境和 DeepSeek 一次配到位
开发语言·人工智能·python·agent
卷无止境42 分钟前
Skill 的安全边界在哪里:风险来源、验证思路与用户可用的防线
后端·python
TomEval1 小时前
【测AI】第22篇:Agent 系统测试方法 — AI 学会“动手“了
人工智能·python·prompt·aigc·测试用例
速易达网络1 小时前
如何“训练”一个 .task 模型
python
PiaoKe___1 小时前
云手机技术解析:从 ARM 虚拟化到 Python 自动化实战
python·智能手机·自动化
学习论之费曼学习法2 小时前
无人值守AI内容矩阵实战(10):Windows 上让 Python 进程 7×24 活着
人工智能·windows·python·矩阵·powershell·进程守护
Norna2 小时前
锁文件里明明有哈希,PDM 为什么说没有?
python