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

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

相关推荐
huangjiazhi_8 分钟前
Python3.14编写文件服务器
python
郭梧悠18 分钟前
算法:有效的括号
python·算法·leetcode
佛珠散了一地25 分钟前
ONNX Runtime GPU 推理配置指南
python
派葛穆1 小时前
Python-pip切换镜像源
开发语言·python·pip
CTA终结者1 小时前
2026年AI量化提效,工具重点要按阶段调整
人工智能·python
xxie1237941 小时前
Python 闭包:函数嵌套的 “状态捕获” 机制
开发语言·python
c_lb72882 小时前
最新AI量化提效,交易认知和技术实现要接上
人工智能·python
机汇五金_2 小时前
钣金外壳定制厂家助力设备升级
大数据·人工智能·python·物联网
xxie1237942 小时前
Python 闭包的调用方法与实践
开发语言·python
HZZD_HZZD2 小时前
用电行为异常检测VAE-基于PyTorch设计用电行为异常检测模型:从时序特征提取到变分自编码器部署的完整实战
人工智能·pytorch·python