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

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

相关推荐
hhy_smile7 分钟前
Python environment and installation
开发语言·python
莫非王土也非王臣1 小时前
网页端的TensorFlow开发实践
人工智能·python·tensorflow
喵手1 小时前
Python爬虫零基础入门【第七章:动态页面入门(Playwright)·第3节】优先 API:用 Network 找接口,回到 Requests(更稳定)!
爬虫·python·playwright·python爬虫实战·python爬虫工程化实战·python爬虫零基础入门·优先 api
我送炭你添花1 小时前
Pelco KBD300A 模拟器:12.设备仿真与虚拟响应生成
python·自动化·运维开发
一晌小贪欢1 小时前
深入解析 Python 3.11 版本迭代:性能飞跃与更优雅的错误处理
python·python基础·python3·python3.11·python小白
理智.6292 小时前
根据requirements.txt 完成环境中的依赖库导入
python·conda·pip
Blossom.1182 小时前
用纯 NLP 打造「零样本」时序预测模型:文本化序列 + LLM 的实战路线
人工智能·python·深度学习·机器学习·自然语言处理·架构·transformer
小二·2 小时前
Python Web 开发进阶实战:AI 编排引擎 —— 在 Flask + Vue 中构建低代码机器学习工作流平台
前端·人工智能·python
sww_10262 小时前
智能问数系统(二):数据分析师Python
java·前端·python
wm10432 小时前
代码随想录第十天 栈和队列
开发语言·python